1.tableview需要頂到頭,也就是從屏幕上邊開始顯示,而不是從導航欄開始
OC
self.autonmaticallyAdjustScrollViewInsets = NO
swift
self.autonmaticallyAdjustScrollViewInsets = false
因為當view controller檢測到scrollview 為主體時,因為autonmaticallyAdjustScrollViewInsets默認為YES,所以加上了inset用來避開導航欄。
2.cell 按下去的效果
//一般在構造cell的代理用設置
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//類型枚舉
typedef NS_ENUM(NSInteger, UITableViewCellSelectionStyle) {
UITableViewCellSelectionStyleNone,//無效果
UITableViewCellSelectionStyleBlue,//藍色
UITableViewCellSelectionStyleGray,//灰色
UITableViewCellSelectionStyleDefault NS_ENUM_AVAILABLE_IOS(7_0)
};
3.cell的分割線
//一般在初始化tableview時設置
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結束的時候 一般用來放置按鈕 填寫頁腳信息等
tableHeaderView 頭視圖一般用來實現頭像 背景墻之類的
代理viewForHeaderInSection group類tableview 每組的頭視圖
代理viewForFooterInSection group類tableview 每組的尾視圖
高度設置0的時候為默認,所以需要不顯示時 設置一個看不到的高度即可比如0.01
tableFooterView置為nil時 多余的cell就不會顯示了
5.xib的cell注冊
xib中腰關聯class
然后在tableview初始化是注冊cell
tableview.registerNib(UINib(nibName: "xibname", bundle: nil), forCellReuseIdentifier: "key")
6.自動適應cell
systrmLayoutSizeFittingSize方法可以將布局中確定的限制條件總和得出寬高但是并沒有什么卵用
7.加載順序
在不同iOS版本中 tableview的cell構造代理 和 cell height代理的加載順序可能不同