问题
UItableView style not changing. I have a tableView controller as one of the tabs of my tab bar controller. I am not able to change the style of UItableView to grouped.
Please help,
回答1:
I would create a new tableViewController and make sure to enable the "also create xib"-like option when giving the tableviewcontroller a name. Copy paste all youre old tablviewcontroller code to the new one and add the xib to the tab window..
回答2:
You must specify the Tableview's style upon creation. Either in IB or by using the method
tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,320,416) style:UITableViewStyleGrouped];
回答3:
You can probably do that in your UITableViewController
s -viewDidLoad
method.
self.tableView.style = UITableViewStyleGrouped;
Edit:
It seems the style
property is actually read only, so the above won't work.
It looks like the table view controller has to be created with -initWithStyle:, but I don't know how to do that from Interface Builder. I'm not at my Mac right now, but will have a look later.
Edit 2:
Here's what I did in Interface Builder:
- Add an instance of
UITableView
and set it up as required, including the style - Hook up your
UITableViewController
as the delegate and data source of theUITableView
- Connect the
UITableView
with theview
outlet of theUITableViewController
. I'm not sure if there is atableView
outlet - if there is, then probably connect it with that one instead.
So, basically, instead of letting the UITableViewController
create its own table view, you provide one in the xib and set up the required connections (delegate, data source, outlet) manually.
来源:https://stackoverflow.com/questions/3618126/uitableview-uitabbar