Ios 如何在TableView中执行多个分段?
我有一个视图控制器,顶部有一个图像视图,中间有一个表视图。TableView有4个部分,每个部分有1到5个单元格。是这样的: 我想给每个单元格添加一个序列Ios 如何在TableView中执行多个分段?,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我有一个视图控制器,顶部有一个图像视图,中间有一个表视图。TableView有4个部分,每个部分有1到5个单元格。是这样的: 我想给每个单元格添加一个序列 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
if (indexPath.section == 0 && indexPath.row < 3) {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.textColor = [UIColor darkGrayColor];
if (indexPath.section == 0 && indexPath.row == 0) {
cell.textLabel.text = @"London";}
if (indexPath.section == 0 && indexPath.row == 1) {
cell.textLabel.text = @"Tokyo";}
if (indexPath.section == 0 && indexPath.row == 2) {
cell.textLabel.text = @"Paris";}
}
[...]
return cell;
}
但是我无法将带有CellIdentifier=@“cell”
的单元格链接到每个视图控制器。在故事板上,从一个单元格到不同的视图控制器设计多个序列是不可能的,所以我该怎么做呢?
谢谢 我找到了问题的解决方案:我只需要选择视图控制器本身,而不是单元格。问题解决了
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0 && indexPath.row == 0) {
[self performSegueWithIdentifier:@"segue1" sender:self];}
if (indexPath.section == 0 && indexPath.row == 1) {
[self performSegueWithIdentifier:@"segue2" sender:self];}
[...]
}