ストーリーボードの他のビューに接続するさまざまなセルとセクションを使用して、プログラムでUITableViewを作成します
セルを接続したいのですが、ユーザーが特定の行を選択すると、新しいビューに移動する必要があります。「ストーリーボードビューで、セルがどのように接続されているかを確認できます」
私の質問は:
このセルをprepareForSegue:、viewDidLoad、didSelectRowAtIndexPath:のコードを作成するビューに接続するにはどうすればよいですか?また、cellForRowAtIndexPath:メソッドで接続のコードを作成する必要があることはわかっていますが、どのように作成すればよいかわかりません。自分
前もって感謝します!
これが私のコードです:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *key = [[self sectionKeys] objectAtIndex:[indexPath section]];
NSArray *contents = [[self sectionContents] objectForKey:key];
NSString *contentForThisRow = [contents objectAtIndex:[indexPath row]];
static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
[[cell textLabel] setText:contentForThisRow];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
_selectedIndex = indexPath.row;
[self.tableView reloadData];
}