私はObjective Cが初めてで、作業中のテーブルで非常に迷っています。私が欲しいのは、セルをクリックすると展開され、別のラベルであるサブビューが表示され、もう一度クリックするとサブビューが非表示になり、元のテキストが表示されることです。現時点では、すべてがひどく間違っており、どのようにコーディングすればよいか本当にわかりません。前提は、答えを明らかにするために展開する質問があることであり、それは簡単だと思いました...これが私のコードです:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// Deselect cell
[tableView deselectRowAtIndexPath:indexPath animated:TRUE];
// create the subview and apply it to the current cell selected
CGRect frame = CGRectMake(0, 0, 160, 50);
UILabel *label = [[UILabel alloc] initWithFrame:frame];
label.text = @"OH";
[cell.contentView addSubview:label];
// Toggle 'selected' state
BOOL isSelected = ![self cellIsSelected:indexPath];
// Store cell 'selected' state keyed on indexPath
NSNumber *selectedIndex = [NSNumber numberWithBool:isSelected];
[selectedIndexes setObject:selectedIndex forKey:indexPath];
// update the view that holds the table
[firstView beginUpdates];
[firstView endUpdates];
//Change cell contents
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
}
誰かが助けを提供できれば、コードを変更してこれをどのように行うべきかを示すことができれば、途方に暮れており、次の数時間でこれを完了する必要があるため、それは素晴らしいことです! ええ。
ありがとう!