开发者

Change UITableViewController's style

开发者 https://www.devze.com 2023-04-02 12:21 出处:网络
How can I subsequently change the style of a UITableView? Edit: Hi, i know how 开发者_如何转开发i set the style with the init-method, but can is change the style after initialization?

How can I subsequently change the style of a UITableView?

Edit: Hi, i know how 开发者_如何转开发i set the style with the init-method, but can is change the style after initialization? Like:

[Self.Style = "Grouped"];

I guess there is no way to do this, isnt it?


Okay nobody seems to really read the question :D

But to answer it: No, it can't be done, you have to re-create it


myTVContoller = [[UITableViewController alloc] initWithStyle:UITableViewStyleGrouped];

or

UITableView *myTable = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];


I suppose you want to change the style of the whole tableview. YOu can do this by following line.

    UITableView *yourTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];


To change a table view style, there are two possibilities: plain or grouped.
You can set these style when you initialize the table view or when you create it on Interface Builder.
You can use something like this:

// Plain Style  
MyTableController *controller = [[MyTableController alloc] initWithStyle:UITableViewStylePlain];  
// Grouped Style  
MyTableController *controller = [[MyTableController alloc] initWithStyle:UITableViewStyleGrouped];

Or in IB, you can select your table view and set its style from Attribute Inspector.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号