1. 程式人生 > >UITableViewStyle設定Group、Plain問題

UITableViewStyle設定Group、Plain問題

1、當建立UIViewController新增UITableView時,

self.tableView =[[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];

2、當建立UITableViewController時,需要改變UITableViewStyle時,

使用self.tableView.style = UITableViewStyleGrouped; 會出現錯誤

ps:

@property (nonatomic, readonly) UITableViewRowActionStyle

style;

UITableViewStylePlain和UITableViewStyleGrouped是UITableViewStyle型別。


查UITableViewController的SDK文件,發現:

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。