0

カスタムセルなどを使用してテーブルビューを設定しました:-

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{SWHNearYouCell *cell = (SWHNearYouCell *)[tableView
                                  dequeueReusableCellWithIdentifier:@"NearYouCell"];

SWHNearYou *aPointer = [self.thingsNearYou objectAtIndex:indexPath.row];
cell.customNearYouLabel.text = aPointer.restrauntsNearYou;
return cell;
}

ボタンを押したときに customNearYouLabel のテキストを変更したいのですが、 -IBAction メソッドでセルへのポインターを取得する方法を考え出しました。

ありがとう

4

3 に答える 3

0

tableView:didSelectRowAtIndexPath:セルを取得することで、メソッドでそれを処理できます。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    cell.customNearYouLabel.text = @"New Text";
}
于 2013-01-24T15:24:25.480 に答える
0

ボタンが表のセル上にないと思いますか?

その場合は、self.thingsNearYou配列内の関連する値を更新するだけです。

[tableView reloadData] を呼び出すと、テーブルのデータがリロードされ、テキストcustomNearYouLabelが変更されます。

于 2013-01-24T15:24:58.920 に答える
0

それを解決しました-tableviewの前にselfを追加する必要がありました

-(IBAction)cancel:(id)sender{


    SWHNearYouCell *cell = (SWHNearYouCell *)[self.tableView
                                          dequeueReusableCellWithIdentifier:@"NearYouCell"];

cell.customNearYouLabel.text = @"New Text";

 NSLog(@"This is it: %@",cell.customNearYouLabel.text);

}

[self.tableView reloadData]; として、もう少し時間を費やす必要があります。テーブルは更新されませんが、解決しやすいはずだと思います。

于 2013-01-25T10:56:48.997 に答える