如何使用didSelectRowAtIndexPath导航到特定的tableview控制器? (迅速)

时间:2014-11-07 04:11:43

标签: ios cocoa-touch swift didselectrowatindexpath

我知道我需要使用didSelectRowAtIndexPath,但不管搜索我似乎找不到简单的解释。

我希望将TableView作为索引用于其他10个ViewControllers,但在查找解释如何将每个单元格链接到后续单元的简单资源时遇到问题TableViewController

2 个答案:

答案 0 :(得分:1)

试试这个:

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    println("You selected cell #\(indexPath.row)!")

    // Show your screen here 
}

答案 1 :(得分:0)

如果您正在获取bodyParts的字典,那么您应该使用如下: 例如

NSDictionary *bodyparts; //containg data from database
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

    let tblView = self.storyboard?.instantiateViewControllerWithIdentifier("Identifier") as UITableViewController
    switch(indexPath.row)
    {
        //data is array of tableviewcontorller
    case 0:
        tblView.Data = [bodyparts objectForKey:@"Arms"];//if You are getting array for key "Arms"
        break;
    case 1:
        tblView.Data = [bodyparts objectForKey:@"Legs"];
        break;
    and so on....
    default:
        break;
    }
}

您必须在故事板中设置故事板标识符

相关问题