0

我最近找到了一种方法来解决在数据存在时而不是在单元格中没有数据时显示按钮的问题。特别是在详细视图(静态单元格)中使用情节提要。这个按钮是故事板上的必需品,因为我已经连接了一些后续接线。

我放置了一个没有背景图像的自定义按钮,并将 tableviewcell 的标记值设置为 1。

然后在我的实现文件中,我覆盖了 cellForRowAtIndexPath。
我的问题是,虽然这很好用,但它是性能密集型的吗?我在这个 MOC 中只有 5 个单元格。这是我的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];

    // need to capture the section and the cell to modify....

    if (cell.tag == 1){

        if (self.map){

            self.mapButton.enabled = YES;

            self.mapLabel.text = @"Click Map for Pic Location...";

            UIImage *buttonImage = [UIImage imageNamed:@"MyMap.png"];
            [self.mapButton setBackgroundImage:buttonImage forState:UIControlStateNormal];


        } else{
            self.mapLabel.text = @"No Location found for Pic";
            self.mapButton.enabled = NO;
        }
    }
    return cell;
}
4

0 回答 0