我有多个单独的视图控制器(我需要),并希望将TableView中的每一行连接到单独的视图控制器。将UITableView单元连接到单独的视图控制器
至于代码,这是我到目前为止。我只是做了的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到数据源和委托。我需要的是将上面的每个条目(一个,两个,三个)连接到单独的视图控制器。我已经制作了所有的视图控制器。