UITableViewStyleGrouped和plain的兩種格式的區(qū)別&tableview indexPathForCell:cell

UITableViewStyleGrouped 頭部視圖和尾部視圖不懸停
UITableViewStylePlain 頭部視圖和尾部視圖懸停

1、當(dāng)創(chuàng)建UIViewController添加UITableView時,
self.tableView =[[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
2、當(dāng)創(chuàng)建UITableViewController時,需要改變UITableViewStyle時,
使用self.tableView.style = UITableViewStyleGrouped; 會出現(xiàn)錯誤
3、當(dāng)創(chuàng)建UITableViewController時,需要改變UITableViewStyle時,
使用self.tableView.style = UITableViewStyleGrouped; 會出現(xiàn)錯誤


ps:
@property(nonatomic,readonly)UITableViewRowActionStylestyle;
UITableViewStylePlain和UITableViewStyleGrouped是UITableViewStyle類型。
查UITableViewController的SDK文檔,發(fā)現(xiàn):
Table views can have one of two styles, UITableViewStylePlain and UITableViewStyleGrouped. When you create a UITableView instance you must specify a table style, and this style cannot be changed.
可以在Xib文件的屬性下直接修改為Group或Plain。

小知識點:NSIndexPath *indexPath = [self.tableview indexPathForCell:cell];

根據(jù)cell返回 cell在tableview中的位置.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容