0

此实用程序应用程序中的视图控制器类(UITableViewController 的子类)用于显示 4 个表视图,其中 3 个通过导航控制器输入。在情节提要中,样式已设置为UITableViewStyleGrouped.

问题:是否可以通过编程方式更改为Style Plain使用索引并释放一些屏幕空间来显示索引?我已经尝试过其他 SO 问题的建议来修改它,initviewDidLoad没有成功。

- (void)viewDidLoad
{
   [super viewDidLoad];
   self.navigationItem.title = self.title;

   if ([[self parentViewController] isKindOfClass:[UITabBarController class]]) {
      [self getNewDataForDate:nil];
      self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
   }
}

编辑1:真正的问题超出了上述代码。更改带有原型单元格(在此处显示为分组)的故事板生成的表格视图的“样式”必须需要一些其他模块来编码。在这里吗?

static NSString *CellIdentifier = @"ListCell";
DetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

结果是这个错误:

Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:]
4

1 回答 1

1

在初始化表格视图时设置表格样式(请参阅 initWithFrame:style:)。此后您无法修改样式。(这是来自Apple 的文档)。

于 2012-05-22T17:30:10.193 回答