简体   繁体   English

故事板中的UITableView-使用UITableViewStyleGrouped初始化

[英]UITableView from storyboard - init with UITableViewStyleGrouped

How do you initialize a UITableViewController to have UITableViewStyleGrouped when it is created in a storyboard? 在情节提要中创建UITableViewController时,如何将其初始化为具有UITableViewStyleGrouped? Normally I would create a grouped table view like this: 通常,我将创建一个分组表视图,如下所示:

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle: UITableViewStyleGrouped];
    if (self) {
    }
    return self;
}

But I realized that this function does not run when you create the UITableViewController in the storyboard. 但是我意识到,在情节提要中创建UITableViewController时,此功能无法运行。 And I do not see any option in the storyboard to set the style to grouped. 而且我在情节提要中看不到任何将样式设置为分组的选项。

Below is a screenshot showing you the option to set group but don't forget to select tableView in your storyboard. 下面的屏幕截图显示了设置的选项,但不要忘记在情节提要中选择tableView。

在此处输入图片说明

There is an option in the storyboard to set the style to grouped but, in order to see it, you must first click in a specific area within the UITableViewController - you must zoom in and click near the top where it says "PROTOTYPE CELLS". 情节提要中有一个选项可以将样式设置为分组,但要查看样式,必须首先单击UITableViewController中的特定区域-必须放大并单击顶部的“ PROTOTYPE CELLS”。 This will select the UITableView itself (as opposed to the controller). 这将选择UITableView本身(而不是控制器)。 Then, in the attributes inspector, you will see the dropdown to set the style to grouped. 然后,在属性检查器中,您将看到将样式设置为分组的下拉列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM