use*_*155 6 iphone xcode uitableview
我已经看过很多次这里被问过,但没有一个解决方案适合我.这是我的代码片段:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellClassName = @"DemoTableViewCell_sched";
DemoTableViewCell_sched *cell = [tableView dequeueReusableCellWithIdentifier:CellClassName];
if (cell == nil)
{
NSArray *topLevelItems = [cellLoader instantiateWithOwner:self options:nil];
cell = [topLevelItems objectAtIndex:0];
}
cell.fooData = [self.bugs objectAtIndex:indexPath.row];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
然后我进来了 ViewDidLoad
cellLoader = [UINib nibWithNibName:@"DemoTableViewCell_sched" bundle:[NSBundle mainBundle]];
Run Code Online (Sandbox Code Playgroud)
小智 20
就我而言,发生的事情是我没有保持对tableview的dataSource的强大指针.因此,当滚动tableview时,数据源已被释放并设置为nil,这导致tableview为numRowsForSection获取0,为cellForRowAtIndexPath获取nils.
如果有人遇到类似问题,您可能会查看是否正确保留了数据源和/或自定义对象.
小智 10
您是否将UITableViewcontroller添加为addSubView?那你应该这样做:
1) addChildViewController,then
2) addSubview
The problem is delegate and datasource of the tableview getting nil since the parent controller unable to a reference to the UITableViewController.
Run Code Online (Sandbox Code Playgroud)
就我而言,问题如下:
我有一个特殊情况,即视图控制器的视图没有以模态方式推送或呈现,但我已将其作为子视图 (view.addSubview) 添加到另一个视图。
这样,实际视图被其超级视图保留,但 ViewController 对象(它是表视图的数据源)没有保留并且内存不足。
我不得不将视图控制器分配给一个(强)变量,以便它留在内存中。
| 归档时间: |
|
| 查看次数: |
6692 次 |
| 最近记录: |