UITableViewCellStyle:

四种Cell类型。

UITableViewCellSeparatorStyle

分割线类型。(group三种,plain两种)

UITableViewCellSelectionStyle

Cell选中的时刻的颜色。

UITableViewCellEditingStyle

编辑状态下的模式。

UITableViewCellAccessoryType

Cell右侧附加view的类型。

======================================================

UITableViewCellStateMask

Cell的状态枚举。


// Content.  These properties provide direct access to the internal label and image views used by the table view cell.  These should be used instead of the content properties below.

@property(nonatomic,readonly,retain) UIImageView  *imageView NS_AVAILABLE_IOS(3_0);   // default is nil.  image view will be created if necessary.

直接访问Cell中的imageview,默认是没有创建的,在设置内容的时刻才会创建。


@property(nonatomic,readonly,retain) UILabel      *textLabel NS_AVAILABLE_IOS(3_0);   // default is nil.  label will be created if necessary.

@property(nonatomic,readonly,retain) UILabel      *detailTextLabel NS_AVAILABLE_IOS(3_0); // default is nil.  label will be created if necessary (and the current style supports a detail label).

同上,需要看Cell类型。


// If you want to customize cells by simply adding additional views, you should add them to the content view so they will be positioned appropriately as the cell transitions into and out of editing mode.

@property(nonatomic,readonly,retain) UIView       *contentView;

每个Cell都会存在一个唯一的contentView,定制cell的时刻我们应该将内容放到这个cell中。这样,我们自定义的内容才能和其他内容一样随着editing状态改变而改变。


// Default is nil for cells in UITableViewStylePlain, and non-nil for UITableViewStyleGrouped. The 'backgroundView' will be added as a subview behind all other views.

@property(nonatomic,retain) UIView                *backgroundView;

背景view

@property(nonatomic,retain) UIView                *selectedBackgroundView;

选中状态下的背景view。


// If not nil, takes the place of the selectedBackgroundView when using multiple selection.

@property(nonatomic,retain) UIView                *multipleSelectionBackgroundView NS_AVAILABLE_IOS(5_0);

多选情况下被选中时的背景view。


关于Cell的复用-----------------------------------------

@property(nonatomic,readonly,copy) NSString       *reuseIdentifier; 返回标识符

- (void)prepareForReuse; // if the cell is reusable (has a reuse identifier), this is called just before the cell is returned from the table view method dequeueReusableCellWithIdentifier:.  If you override, you MUST call super.

子类可以通过覆写这个方法,那么在Cell在复用之前调用这个方法做些操作。

@property(nonatomic) UITableViewCellSelectionStyle  selectionStyle;             // default is UITableViewCellSelectionStyleBlue.

设置Cell选中状态的颜色


@property(nonatomic,getter=isSelected) BOOL         selected;                   // set selected state (title, image, background). default is NO. animated is NO

设置是否为选中状态。


@property(nonatomic,getter=isHighlighted) BOOL      highlighted;                // set highlighted state (title, image, background). default is NO. animated is NO

设置是否为高亮,高亮就是处于选中状态下的显示效果。

http://www.ekeol.com/forum/9423


- (void)setSelected:(BOOL)selected animated:(BOOL)animated;                     // animate between regular and selected state

带动画设置选中状态。


- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated;               // animate between regular and highlighted state

带动画设置高亮状态。


@property(nonatomic) BOOL   shouldIndentWhileEditing;   // default is YES.  This is unrelated to the indentation level below.

编辑状态下是否显示缩进。(必须在

editingStyleForRowAtIndexPath代理方法中将返回值设为none,也就是说编辑状态下不能有删除增加等按钮。

)你也许会觉得如果没有这些按钮,就算不设置这个属性为No也是一样的,事实上就算没有添加删除按钮,cell前面也会有缩进。(这个方法与indentationLevel没有联系)


@property(nonatomic) UITableViewCellAccessoryType   accessoryType;  // default is UITableViewCellAccessoryNone. use to set standard type

设置右侧附加视图类型(系统类型)。


@property(nonatomic,retain) UIView                 *accessoryView;              // if set, use custom view. ignore accessoryType. tracks if enabled can calls accessory action

自定义右侧附加视图。


@property(nonatomic) UITableViewCellAccessoryType   editingAccessoryType;       // default is UITableViewCellAccessoryNone. use to set standard type

编辑状态下,右侧附加视图样式。(可以与移动按钮并存,会自动分开)

@property(nonatomic,retain) UIView                 *editingAccessoryView;       // if set, use custom view. ignore editingAccessoryType. tracks if enabled can calls accessory action

编辑状态下,右侧的自定义附加视图

@property(nonatomic) NSInteger                      indentationLevel;           // adjust content indent. default is 0

@property(nonatomic) CGFloat                        indentationWidth;           // width for each level. default is 10.0

这两个属性用来设置不同层次结构的内容的缩进大小。


@property(nonatomic,getter=isEditing) BOOL          editing;                    // show appropriate edit controls (+/- & reorder). By default -setEditing: calls setEditing:animated: with NO for animated.

设置某一个Cell的编辑状态,设置TableView会改变所有cell的状态。但是设置这个值为YES只能使当前cell出现右边的附加视图,前面的编辑按钮和后面的移动按钮都无法出现。

- (void)setEditing:(BOOL)editing animated:(BOOL)animated;

带动画的设置。

----------------------------

- (void)willTransitionToState:(UITableViewCellStateMask)state NS_AVAILABLE_IOS(3_0);

- (void)didTransitionToState:(UITableViewCellStateMask)state NS_AVAILABLE_IOS(3_0);

这两个方法应该在子类中覆写,当前Cell的状态发生改变的时刻就会触发这些方法,可以在这些方法中进行一些额外的操作。(例如:cell被点击以后就会进入

UITableViewCellStateShowingDeleteConfirmationMask 状态)

[置顶] UITableViewCell的更多相关文章

  1. IOS 作业项目 TableView两个section中cell置顶功能实现

    点击cell会置顶,其他的下移

  2. 【iOS开发系列】cell切割线置顶

    废话不多说,直接上代码: /** * tableViewCell切割线左側置顶 < 1 > */ -(void)viewDidLayoutSubviews { if ([_tableVie ...

  3. 在UWP中页面滑动导航栏置顶

    最近在研究掌上英雄联盟,主要是用来给自己看新闻,顺便copy个界面改一下段位装装逼,可是在我copy的时候发现这个东西 当你滑动到一定距离的时候导航栏会置顶不动,这个特性在微博和淘宝都有,我看了@ms ...

  4. WinFrom窗体始终置顶

    调用WindowsAPI使窗体始终保持置顶效果,不被其他窗体遮盖: [DllImport("user32.dll", CharSet = CharSet.Auto)] privat ...

  5. winform窗体置顶

    winform窗体置顶 金刚 winform 置顶 今天做了一个winform小工具.需要设置置顶功能. 网上找了下,发现百度真的很垃圾... 还是必应靠谱些. 找到一个可以链接. https://s ...

  6. 自定义置顶TOP按钮

    简述一下,分为三个步骤: 1. 添加Html代码 2. 调整Css样式 3. 添加Jquery代码 具体代码如下: <style type="text/css"> #G ...

  7. ahk之路:利用ahk在window7下实现窗口置顶

    操作系统:win7 64位 ahk版本:autohotkey_L1.1.24.03 今天安装了AutoHotkey_1.1.24.03.SciTE.PuloversMacroCreator,重新开始我 ...

  8. Qt中让Qwidget置顶的方法

    一般来是说窗体置顶和取消只要        setWindowFlags(Qt::WindowStaysOnTopHint);        setWindowFlags(Qt::Widget); 要 ...

  9. js之滚动置顶效果

    0.js获取高度 ? 1 2 3 4 5 6 document.all   // 只有ie认识   document.body.clientHeight              // 文档的高,屏幕 ...

随机推荐

  1. 利用CART算法建立分类回归树

    常见的一种决策树算法是ID3,ID3的做法是每次选择当前最佳的特征来分割数据,并按照该特征所有可能取值来切分,也就是说,如果一个特征有四种取值,那么数据将被切分成4份,一旦按某特征切分后,该特征在之后 ...

  2. jquery 只有二级下拉菜单

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. 不为人知的Locked

    在属性面板上,有一个Locked属性,什么时候添加上去的,真是没有注意到,它的说明为:确定是否可以移动控件或调整控件的大小,默认是为false的,设置为true以后,当前选中的控件会在左上角出现一个锁 ...

  4. Django 入门

    Django 入门 Django是一个开放源代码的Web应用框架,由Python写成.采用了MVC的软件设计模型,即模型M,视图V和控制器C.它最初是被开发来用于管理劳伦斯出版集团旗下的一些以新闻内容 ...

  5. DATE 使用

    DATE 使用 标签(空格分隔): SHELL 使用shell处理文本时经常要使用date,但各种参数经常忘,记录在此: #date 获取当前时间 #date -d "-1 week&quo ...

  6. 很少有人知道的c++中的try块函数

    c++有一些在现实世界中很少看到的结构.这些结构有着自己的用法,但是要特别小心保守的予以运用.就像是网站 The Old New Thing首页标题上面的说的那样: “代码通常被读的次数原因超过了被写 ...

  7. python使用__future__

    Python的新版本会引入新的功能,但是,实际上这些功能在上一个老版本中就已经存在了.要“试用”某一新的特性,就可以通过导入__future__模块的某些功能来实现. 例如,Python 2.7的整数 ...

  8. 解决Tomcat无法加载css和js等静态资源文件

    解决思路有两个 一是,你使用了Apache服务器,html不交给Tomcat处理,所以你找不到Html等静态资源,所以你先停掉阿帕奇,然后只用Tomcat猫试试. 二是,像我一样,使用了Jetty开发 ...

  9. 树莓派(jessie)制作服务并开机启动

    /etc/init.d/xware #!/bin/sh ### BEGIN INIT INFO # Provides: svn_serve # Required-Start: $remote_fs # ...

  10. 客户端(C#)调用CXF搭建的webservice的出现一些问题记录

    最近把XFire框架搭建的一个webservice换成CXF框架.访问webservice的客户端是C#写的.客户端调用webservice,数据能在客户端得到.看起来显然是成功了. 但其中在VS中添 ...