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