1

我正在使用一个UITableViewController作为源,目标是带有 UITableView 的 UIViewController。

我想要push from (a) tableViewCell (in a custom cell of a tableview in .xib) to (b) viewController。自定义单元格在 .xib 文件中指定。我已经尝试控制拖动来创建 segue,但我无法做到这一点。

如何从 customCell 推送到 UIViewController?我努力了

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

    let destination = FestsViewController()
    navigationController?.pushViewController(destination, animated: true)}

我得到没有标签的黑色背景。 在此处输入图像描述

4

1 回答 1

0

你不能。Segues 仅在情节提要中可用。您必须在 中手动进行导航 -tableView:didSelectRowAtIndexPath

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //some checks 
    //...

    UIViewController *destinationVC = //init it with nib or instantiate from storyboard   
    //pass some parameters if you need
    //e.g.
    //destinationVC.prop1 = someValue; 
    [self.navigationController pushViewController:destinationVC animated:YES];
}
于 2015-11-21T08:39:23.580 回答