UITableViewCell类学习

  • Figure 5-1  Parts of a table view cell


     

     

    Figure 5-2  Parts of a table-view cell in editing mode


     

     

    Figure 5-3  Default cell content in a UITableViewCell object


     

    源文档 <https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html#//apple_ref/doc/uid/TP40007451-CH7>

     

    如上是一个table view cell的组成视图(第二张是编辑状态下的)。

    如下是参看iOS源文档整理的UITableViewCell类的属性及方法。

     

    1. - (instancetype)initWithStyle:(UITableViewCellStyle)style  reuseIdentifier:(NSString *)reuseIdentifier

    Initializes a table cell with a style and a reuse identifier and returns it to the caller.

    使用指定的风格和重用ID初始化一个table cell

    该方法会在tableView调用dequeueReusableCellWithIdentifier:时被调用

     

    typedef enum : NSInteger {

       UITableViewCellStyleDefault,

       UITableViewCellStyleValue1,

       UITableViewCellStyleValue2,

       UITableViewCellStyleSubtitle

    } UITableViewCellStyle;

     

     

    1. @property(nonatomic, readonly, copy) NSString *reuseIdentifier

    A string used to identify a cell that is reusable. (read-only)

    标记一个可复用的cell字符串,只读

     

    1. - (void)prepareForReuse

    Prepares a reusable cell for reuse by the table view'€™s delegate.

    table view的委托准备一个可复用的cell

    该方法会在tableView调用dequeueReusableCellWithIdentifier:方法时在返回cell前被调用,该方法仅可以修改除内容外的cell的属性,如透明度、编辑或选中时的状态等,其他与内容相关的(图片、文本框等)在委托方法

     tableView:cellForRowAtIndexPath:中修改

     

    1. @property(nonatomic, readonly, retain) UILabel *textLabel

    Returns the label used for the main textual content of the table cell. (read-only)

    返回cell内容的主要文本框的文本对象,对象

     

    1. @property(nonatomic, readonly, retain) UILabel *detailTextLabel

    Returns the secondary label of the table cell if one exists. (read-only)

    返回cell的第二部分文本对象,只读

    cell风格为UITableViewCellStyleDefault时该属性可忽略

     

    1. @property(nonatomic, readonly, retain) UIImageView *imageView

    Returns the image view of the table cell. (read-only)

    返回cell的图片视图,只读

     

    1. @property(nonatomic, readonly, retain) UIView *contentView

    Returns the content view of the cell object. (read-only)

    返回cell的内容视图,只读

    该视图是其他自定义视图的容器,可通过addSubView方法来嵌入自定义视图

     

    1. @property(nonatomic, retain) UIView *backgroundView

    The view used as the background of the cell.

    cell的背景视图

     

    1. @property(nonatomic, retain) UIView *selectedBackgroundView

    The view used as the background of the cell when it is selected.

    cell被选中时的背景视图

     

    1. @property(nonatomic, retain) UIView *multipleSelectionBackgroundView

    The background view to use for a selected cell when the table view allows multiple row selections.

    多行cell被选中时的背景视图

    可通过tableView对象的 allowsMultipleSelection属性和allowsMultipleSelectionDuringEditing 属性来使能多行选则

     

    1. @property(nonatomic) UITableViewCellAccessoryType accessoryType

    The type of standard accessory view the cell should use (normal state).

    标准附加视图风格

    accessoryView属性被设置时本属性可被忽略

     

    typedef enum : NSInteger {

       UITableViewCellAccessoryNone,

       UITableViewCellAccessoryDisclosureIndicator,

       UITableViewCellAccessoryDetailDisclosureButton,

       UITableViewCellAccessoryCheckmark,

       UITableViewCellAccessoryDetailButton

    } UITableViewCellAccessoryType;

     

    1. @property(nonatomic, retain) UIView *accessoryView

    A view that is used, typically as a control, on the right side of the cell (normal state).

    cell附加视图

    若该属性为nil可通过accessoryType 选择附加视图的显示风格

     

     

    1. @property(nonatomic) UITableViewCellAccessoryType editingAccessoryType

    The type of standard accessory view the cell should use in the table view’s editing state.

    cell附加视图在编辑状态下的标准风格

    editingAccessoryView被设置时本属性可被忽略

     

    1. @property(nonatomic, getter=isSelected) BOOL selected

    A Boolean value that indicates whether the cell is selected.

    指示cell是否被选中,可设置该属性为YES使cell处在被选中状态(非动画)

     

    1. @property(nonatomic) UITableViewCellSelectionStyle selectionStyle

    The style of selection for a cell.

    cell被选中时的风格

     

    typedef enum : NSInteger {

       UITableViewCellSelectionStyleNone,

       UITableViewCellSelectionStyleBlue,

       UITableViewCellSelectionStyleGray,

       UITableViewCellSelectionStyleDefault

    } UITableViewCellSelectionStyle;

     

    1. - (void)setSelected:(BOOL)selected  animated:(BOOL)animated

    Sets the selected state of the cell, optionally animating the transition between states.

    设置cell处在被选中状态,动画方式(可选)

     

    1. @property(nonatomic, getter=isHighlighted) BOOL highlighted

    A Boolean value that indicates whether the cell is highlighted.

    指示cell是否处在高亮的状态,可设置该属性为YES使cell处在高亮状态(非动画)

     

    1. - (void)setHighlighted:(BOOL)highlighted    animated:(BOOL)animated

    Sets the highlighted state of the cell, optionally animating the transition between states.

    设置cell处在高亮状态,动画方式(可选)

     

    1. @property(nonatomic, getter=isEditing) BOOL editing

    A Boolean value that indicates whether the cell is in an editable state.

    指示cell是否处在可编辑状态

     

    1. - (void)setEditing:(BOOL)editing    animated:(BOOL)animated

    Toggles the receiver into and out of editing mode.

    触发接收者进入或退出编辑模式,动画(可选)

     

    1. @property(nonatomic, readonly) UITableViewCellEditingStyle editingStyle

    The editing style of the cell. (read-only)

    cell编辑风格,只读,默认为 UITableViewCellEditingStyleNone

    具体某个cell的风格可在UITableViewDelegate中的方法

    - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView   editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 设置

     

    typedef enum : NSInteger {

       UITableViewCellEditingStyleNone,

       UITableViewCellEditingStyleDelete,

       UITableViewCellEditingStyleInsert

    } UITableViewCellEditingStyle;

     

    1. @property(nonatomic, readonly) BOOL showingDeleteConfirmation

    Returns whether the cell is currently showing the delete-confirmation button. (read-only)

               返回当前cell是否显示“删除-确认”按钮  

     

            

    1. @property(nonatomic) BOOL showsReorderControl

               A Boolean value that determines whether the cell shows the reordering control.

              决定cell是否显示重新排序控件

     

    1. - (void)willTransitionToState:(UITableViewCellStateMask)state

    Called on the cell just before it transitions between cell states

    cell状态间过渡前调用

     

    typedef enum : NSUInteger {

       UITableViewCellStateDefaultMask                     = 0,

       UITableViewCellStateShowingEditControlMask          = 1 << 0,

       UITableViewCellStateShowingDeleteConfirmationMask   = 1 << 1

    } UITableViewCellStateMask;

     

    1. - (void)didTransitionToState:(UITableViewCellStateMask)state

    Called on the cell just after it transitions between cell states.

    cell状态间过渡后调用

     

    1. @property(nonatomic) NSInteger indentationLevel

               The indentation level of the cell’s content.

               cell内容的缩进等级

     

              

    1. @property(nonatomic) CGFloat indentationWidth

               The width for each level of indentation of a cell'€™s content.

                。。。

     

     

    1. @property(nonatomic) UIEdgeInsets separatorInset

               The inset values for the cell’s content.

               cell内容的“嵌入”

              可使用本属性调整cell内容的左右边界

     

    源文档 <https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewCell_Class/index.html#//apple_ref/occ/instp/UITableViewCell/separatorInset

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
目标检测(Object Detection)是计算机视觉领域的一个核心问题,其主要任务是找出图像中所有感兴趣的目标(物体),并确定它们的别和位置。以下是对目标检测的详细阐述: 一、基本概念 目标检测的任务是解决“在哪里?是什么?”的问题,即定位出图像中目标的位置并识别出目标的别。由于各物体具有不同的外观、形状和姿态,加上成像时光照、遮挡等因素的干扰,目标检测一直是计算机视觉领域最具挑战性的任务之一。 二、核心问题 目标检测涉及以下几个核心问题: 分问题:判断图像中的目标属于哪个别。 定位问题:确定目标在图像中的具体位置。 大小问题:目标可能具有不同的大小。 形状问题:目标可能具有不同的形状。 三、算法分 基于深度学习的目标检测算法主要分为两大: Two-stage算法:先进行区域生成(Region Proposal),生成有可能包含待检物体的预选框(Region Proposal),再通过卷积神经网络进行样本分。常见的Two-stage算法包括R-CNN、Fast R-CNN、Faster R-CNN等。 One-stage算法:不用生成区域提议,直接在网络中提取特征来预测物体分和位置。常见的One-stage算法包括YOLO系列(YOLOv1、YOLOv2、YOLOv3、YOLOv4、YOLOv5等)、SSD和RetinaNet等。 四、算法原理 以YOLO系列为例,YOLO将目标检测视为回归问题,将输入图像一次性划分为多个区域,直接在输出层预测边界框和别概率。YOLO采用卷积网络来提取特征,使用全连接层来得到预测值。其网络结构通常包含多个卷积层和全连接层,通过卷积层提取图像特征,通过全连接层输出预测结果。 五、应用领域 目标检测技术已经广泛应用于各个领域,为人们的生活带来了极大的便利。以下是一些主要的应用领域: 安全监控:在商场、银行
目标检测(Object Detection)是计算机视觉领域的一个核心问题,其主要任务是找出图像中所有感兴趣的目标(物体),并确定它们的别和位置。以下是对目标检测的详细阐述: 一、基本概念 目标检测的任务是解决“在哪里?是什么?”的问题,即定位出图像中目标的位置并识别出目标的别。由于各物体具有不同的外观、形状和姿态,加上成像时光照、遮挡等因素的干扰,目标检测一直是计算机视觉领域最具挑战性的任务之一。 二、核心问题 目标检测涉及以下几个核心问题: 分问题:判断图像中的目标属于哪个别。 定位问题:确定目标在图像中的具体位置。 大小问题:目标可能具有不同的大小。 形状问题:目标可能具有不同的形状。 三、算法分 基于深度学习的目标检测算法主要分为两大: Two-stage算法:先进行区域生成(Region Proposal),生成有可能包含待检物体的预选框(Region Proposal),再通过卷积神经网络进行样本分。常见的Two-stage算法包括R-CNN、Fast R-CNN、Faster R-CNN等。 One-stage算法:不用生成区域提议,直接在网络中提取特征来预测物体分和位置。常见的One-stage算法包括YOLO系列(YOLOv1、YOLOv2、YOLOv3、YOLOv4、YOLOv5等)、SSD和RetinaNet等。 四、算法原理 以YOLO系列为例,YOLO将目标检测视为回归问题,将输入图像一次性划分为多个区域,直接在输出层预测边界框和别概率。YOLO采用卷积网络来提取特征,使用全连接层来得到预测值。其网络结构通常包含多个卷积层和全连接层,通过卷积层提取图像特征,通过全连接层输出预测结果。 五、应用领域 目标检测技术已经广泛应用于各个领域,为人们的生活带来了极大的便利。以下是一些主要的应用领域: 安全监控:在商场、银行
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值