2012-07-03 22 views
2

我有一个表视图控制器与两个静态单元格。点击时,每个人都应该打开一个预定的视图。如果这更容易理解,每个单元格应该像标签栏中的元素一样。我试图用push segue将每个单元格连接到它的视图,但是看起来像当我这样做时,故事板正在为整个表格设置推送。如何告诉静态单元在Xcode中打开特定视图?

如何将每个单元格连接到开放式唯一视图?

(我愿意常规视图控制器,2个按钮来实现这一点,而不是表也是如此。)

回答

4

采用你们班的UITableViewDelegate协议,并实现

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 

    if ((indexPath.section == customSection) && (indexPath.row == customRow)) 
    { 
     // Your custom action here 
    } 
} 
+0

在“您的自定义操作”中,如何以编程方式打开我想要的视图? – Orchid

+0

我想这取决于你的“预定视图”是什么。例如,如果你打算推另一个视图控制器,你可以调用[self.navigationController pushViewController:nextViewController animated:YES]; – Marco

0
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 

    if ((indexPath.section == customSection) && (indexPath.row == customRow)) 
    { 
     // Your custom action here 
    } 
} 

http://texnikal.ru

相关问题