revealViewController 中的 didSelectRowAtIndexPath

didSelectRowAtIndexPath in revealViewController

我正在使用 revealViewController,在这个 revealViewController 中,我想根据本教程创建一个带有自定义单元格的 UITableViewhttps://www.youtube.com/watch?v=EVJiprvRLoo

这是我的代码:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let vcName = identities[indexPath.row]
let viewController = storyboard?.instantiateViewControllerWithIdentifier(vcName)
self.navigationController?.pushViewController(viewController!, animated: true)
}

我正在使用故事板,但我没有遇到任何问题,但它不起作用。

我也尝试过向该视图控制器推送 segue,但后来我的 navigationViewController 消失了,我认为使用代码会更容易。

抱歉,如果我的问题不准确,但希望您能理解。

非常感谢。

您的 self.navigationController? 为零。你应该这样做:

let vcName = identities[indexPath.row]
let viewController = storyboard?.instantiateViewControllerWithIdentifier(vcName)
let navVC = UINavigationController(rootViewController:viewController)

然后通过SWRevealViewController:

的方法设置前视图控制器

- (void)pushFrontViewController:(UIViewController *)frontViewController animated:(BOOL)animated;

self.revealViewController.pushFrontViewController(navVC, animated:true)

你必须推送到 RevealController 而不是 ViewController