我需要調用一個方法的行被添加到表格視圖後,但和我想這iOS的自定義表格視圖單元格是空
if (_tableView) {
[self.currentDownloads insertObject:url atIndex:0];
NSLog(@"%@", _currentDownloads);
[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];
ACDownloadCell *cell = (ACDownloadCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
[cell downloadFileAtURL:url];
}
else{
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 499) style:UITableViewStylePlain];
self.tableView.dataSource = self;
self.tableView.delegate = self;
[self.view addSubview:self.tableView];
[self.currentDownloads insertObject:url atIndex:0];
NSLog(@"%@", _currentDownloads);
[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];
ACDownloadCell *cell = (ACDownloadCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
NSLog(@"%@", cell);
[cell downloadFileAtURL:url];
}
,當它記錄cell
,它記錄(null)
。你看到這裏有什麼不正確的東西嗎?這裏是我的tableView:cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
ACDownloadCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ACDownloadCell" owner:nil options:nil];
for(id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[ACDownloadCell class]])
{
cell = (ACDownloadCell *)currentObject;
break;
}
}
}
return cell;
}