0
我不明白我爲什麼收到此消息以及如何解決此問題。在TableViewCell中使用未聲明的標識符「單元格」
在我下面的代碼,包含「細胞」每一行給了我一個消息「未聲明的標識符‘細胞’的使用」 ...
static NSString *CellIdentifier = @"LocationCell";
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
(LocationsTableViewCellController *)cell = (LocationsTableViewCellController *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
Feed *feed = [_feeds objectAtIndex:indexPath.row];
cell.phraseLabel.text = feed.title;
//cell.detailTextLabel.text = new.place;
//cell.imageView.image = [UIImage imageNamed:@"location.png"];
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_feeds count];
}
你在第一行所做的是將'cell'類型轉換爲LocationsTableViewCellController而不是聲明它。使用LocationsTableViewCellController * cell ='。另外,如果您正在使用'dequeue',那麼您可能需要添加'cell == nil'條件來確保。有時可能會崩潰。 – n00bProgrammer