UITableView:UIScrollView<NSCoding>
1.創(chuàng)建一個(gè)UITableView對(duì)象
UITableView *tableView = [[UITableView alloc]initWithFrame:[UIScreen mainScreen] bounds] style: UITableViewStylePlain];
2.separatorColor 分割線顏色
tableView.separatorColor = [UIColor redColor];
3.rowHeight 調(diào)整每個(gè)cell點(diǎn)高度(默認(rèn)44)
tableView.rowHeight = 60;
4.reloadData 刷新數(shù)據(jù)
[tableView reloadData];
5.<UITableViewDelegate , UITableViewDataSouece>
倆個(gè)必須實(shí)現(xiàn)的方法
numberOfRowsInSection 控制一個(gè)section中cell的多少
cellForRowAtIndexPath 控制cell中的內(nèi)容
didSelectedRowAtIndexPath 選中cell時(shí)候使用的方法
didDeseletRowAtIndexPath 取消選中的時(shí)候用的方法
numberOfSectionInTableView 控制分區(qū)的個(gè)數(shù)
titleForHeaderInSection section上Header顯示的內(nèi)容
titleForHeaderInSection section上Header顯示的內(nèi)容
heightForHeaderInSetion section頂部的高度
heightForRowAtIndexPath cell的高度
sectionIndexTitlesForTableView 該方法返回值用于在表格右邊建立一個(gè)浮動(dòng)的索引
cell相關(guān)
1 cellForRowAtIndexPath 返回表格中指定indexPath對(duì)應(yīng)的cell
2 indexPathForCell 返回指定cell的indexPath
3 indexPathForRowAtPoint 返回表格中指定點(diǎn)所在的indexPath
4 indexPathForRowsInRect 返回表格中指定區(qū)域內(nèi)所有indexPath 組成的數(shù)組
5. visibleCells 返回表格中所有課件區(qū)域內(nèi)cell的數(shù)組
UITableViewCell : UIView<NSCoding ,UIGestureRecognizerDelegate>這里涉及到自定義 UITableViewCell 以下為具體步驟以及需要注意到的地方
1.首先創(chuàng)建一個(gè)類繼承UITableViewCell
2.把自定義cell上到自定義視圖全部設(shè)置為屬性(注意:屬性名一定不要和系統(tǒng)屬性名重復(fù) imageView textLabell detaiTextLabel)
3.在cell的初始化方法中 對(duì)自定義視圖對(duì)屬性初始化饭豹,在初始化時(shí)候可以不指定frame(注意:這里加載到視圖上時(shí)添履,加載到contentView上 同時(shí)注意內(nèi)存管理)
4.在layoutSubviews方法中完成最后操作 通常給出frame (注意卸留,這個(gè)方法為系統(tǒng)自帶方法,當(dāng)一個(gè)cell顯示到屏幕上之前,最后調(diào)用到一個(gè)方法楚午,所有cell到操作 包括賦值 調(diào)整高度等 都已經(jīng)完成 一定不要忘記[super layoutSubViews];)
轉(zhuǎn)自 http://www.reibang.com/p/344ffc33a435
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者