UItableView + UItabbar

寵の児 提交于 2020-01-06 15:20:10

问题


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 UITableViewControllers -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:

  1. Add an instance of UITableView and set it up as required, including the style
  2. Hook up your UITableViewController as the delegate and data source of the UITableView
  3. Connect the UITableView with the view outlet of the UITableViewController. I'm not sure if there is a tableView 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!