stktrc
stktrc

Reputation: 1639

UITableView inside a scroll, inside of a UINavigationController can't pushViewController

I have a UINavigationController. It has it's main view controller, which holds a scrollview and then 2 table views inside of that and a button. If i set the button to pushViewController on tap, this works fine. If i set either of the tableviews to pushViewController on didSelectRow, nothing happens. I tested by making the tableViews print the self.navigationController on tap, and that prints nil, so i know for some reason it's not inheriting the nav controller properly.

This is in swift. I can get this working fine, in the exact same way in ObjC no problem.

Upvotes: 0

Views: 95

Answers (1)

rnsjtngus
rnsjtngus

Reputation: 225

You can override tableview's function

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    let YourVC = YourViewController();
    YourVC.data = self.data[indexPath.section][indexPath.row];
    self.navigationController?.pushViewController(YourVC, animated: true);
}

Upvotes: 1

Related Questions