我有多個單獨的視圖控制器(我需要),並希望將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到數據源和委託。我需要的是將上面的每個條目(一個,兩個,三個)連接到單獨的視圖控制器。我已經制作了所有的視圖控制器。