複数の個別のView Controller(必要)があり、TableViewの各行を個別のView Controllerに接続したいと考えています。
コードに関しては、これは私がこれまでに持っているものです。私はtableViewを作っただけです:
私のViewController.h
[...]
@interface SimpleTableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
[...]
私のViewController.m
[...]
@implementation SimpleTableViewController
{
NSArray *tableData;
}
[...]
- (void)viewDidLoad
{
[super viewDidLoad];
tableData = [NSArray arrayWithObjects:@"One", @"Two", @"Three", nil];
}
[...]
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tableData count];
}
[...]
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
return cell;
}
また、tableView を dataSource とデリゲートに接続しました。必要なのは、上記の各エントリ (1、2、3) を個別のビュー コントローラーに接続することです。私はすでにすべてのView Controllerを作成しました。