1.tableview需要頂?shù)筋^,也就是從屏幕上邊開始顯示,而不是從導(dǎo)航欄開始
OC
self.autonmaticallyAdjustScrollViewInsets = NO
swift
self.autonmaticallyAdjustScrollViewInsets = false
因?yàn)楫?dāng)view controller檢測(cè)到scrollview 為主體時(shí),因?yàn)閍utonmaticallyAdjustScrollViewInsets默認(rèn)為YES,所以加上了inset用來避開導(dǎo)航欄。
2.cell 按下去的效果
//一般在構(gòu)造cell的代理用設(shè)置
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//類型枚舉
typedef NS_ENUM(NSInteger, UITableViewCellSelectionStyle) {
UITableViewCellSelectionStyleNone,//無效果
UITableViewCellSelectionStyleBlue,//藍(lán)色
UITableViewCellSelectionStyleGray,//灰色
UITableViewCellSelectionStyleDefault NS_ENUM_AVAILABLE_IOS(7_0)
};
3.cell的分割線
//一般在初始化tableview時(shí)設(shè)置
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//類型枚舉
typedef NS_ENUM(NSInteger, UITableViewCellSeparatorStyle) {
UITableViewCellSeparatorStyleNone,
UITableViewCellSeparatorStyleSingleLine,
UITableViewCellSeparatorStyleSingleLineEtched // This separator style is only supported for grouped style table views currently
} __TVOS_PROHIBITED;
4.head and foot
tableFooterView tableview結(jié)束的時(shí)候 一般用來放置按鈕 填寫頁腳信息等
tableHeaderView 頭視圖一般用來實(shí)現(xiàn)頭像 背景墻之類的
代理viewForHeaderInSection group類tableview 每組的頭視圖
代理viewForFooterInSection group類tableview 每組的尾視圖
高度設(shè)置0的時(shí)候?yàn)槟J(rèn),所以需要不顯示時(shí) 設(shè)置一個(gè)看不到的高度即可比如0.01
tableFooterView置為nil時(shí) 多余的cell就不會(huì)顯示了
5.xib的cell注冊(cè)
xib中腰關(guān)聯(lián)class
然后在tableview初始化是注冊(cè)cell
tableview.registerNib(UINib(nibName: "xibname", bundle: nil), forCellReuseIdentifier: "key")
6.自動(dòng)適應(yīng)cell
systrmLayoutSizeFittingSize方法可以將布局中確定的限制條件總和得出寬高但是并沒有什么卵用
7.加載順序
在不同iOS版本中 tableview的cell構(gòu)造代理 和 cell height代理的加載順序可能不同