クリックすると展開して他のコンテンツを表示する動的テーブルを作成しようとしています。テーブルにNSMutableArrayからの情報が入力されるようになりました。各セルを押すこともでき、2倍のサイズに拡大します。さて、やや面倒であることが証明されている次のステップは、セルをクリックしたときに新しい/代替テキストを表示するようにすることです。まず、セットアップ方法は次のとおりです。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
NSString *cellValue = [cellContent objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
return cell;
}
そしてこの後、私はセルがプレスで拡大する方法を持っています:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
// If our cell is selected, return double height
if([self cellIsSelected:indexPath]) {
return kCellHeight * 2.0;
[cellContent replaceObjectAtIndex:[self cellIsSelected:indexPath] withObject:@"NEW STUFF HERE"];
}
セルに触れても何も変わらないので、これは間違った方法で行っているに違いありません。タッチで新しい/代替テキストを表示するにはどうすればよいですか?どんな助けでもすごいです、それはかなり簡単なことである可能性が高いと思います、しかし私は今それを見ることができません。
ありがとう!