【问题标题】:Getting all nil properties of UITableViewCell in iOS 10.0在 iOS 10.0 中获取 UITableViewCell 的所有 nil 属性
【发布时间】:2016-08-16 07:06:16
【问题描述】:

我在 iOS 10 中获得了所有属性为零的单元格,但它在 iOS 9.0 中工作。我刚刚使用了一个自定义类的单元格,并在 viewDidLoad 中注册了该单元格并在 cellForRowAtIndexPath 中使用它。

viewDidLoad

[self.tblVw registerClass:[TaskListCell class] forCellReuseIdentifier:@"TaskassignmentCellForStaff"];

cellForRowAtIndexPath

TaskListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TaskassignmentCellForStaff" forIndexPath:indexPath];

谁能告诉我应该是什么原因。

谢谢。

【问题讨论】:

  • 是的,这里的一些代码可以帮助...
  • 如果您使用 Storyboard,则无需registerCell
  • 你使用storyboard还是XIB?
  • @dipenPanchasara 我之前没有声明它,但是如果我没有注册 Cell,iOS 10 应用程序会崩溃。是的,我正在使用故事板
  • 你在 xib 中使用自定义单元格吗?

标签: objective-c uitableview ios10


【解决方案1】:

正如 Dipen Panchasara 所说,如果您使用 Storyboard,则无需注册Cell。

1) 我从头开始制作了一个新应用。

2) 创建类TaskListCell

3) 创建一个 TVC TaskListController 4) 无需注册

5) 我只是写了:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    TaskListCell * cell = (TaskListCell*) [tableView dequeueReusableCellWithIdentifier:
                                           @"TaskassignmentCellForStaff"
                                                                          forIndexPath:indexPath];
    // Configure the cell...

    return cell;
}

ps 代码以 Zip 形式在此处。请随时与我联系。

Xcode 8.0 测试版 6

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-07
    • 2014-05-30
    • 1970-01-01
    • 2013-04-05
    • 1970-01-01
    • 2020-06-30
    相关资源
    最近更新 更多