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

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值