push from custom cell nib to viewController

380 Views Asked by At

I'm using a UITableViewController as Source, the destination is a UIViewController with a UITableView.

I want to push from (a) tableViewCell (in a custom cell of a tableview in .xib) to (b) viewController . The custom cell is specified in a .xib file. I have tried control drag to create segue but I'm not able to do that.

How can I c push from the customCell to the UIViewController? I have tried

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

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

I am getting black background with no labels . enter image description here

1

There are 1 best solutions below

8
On BEST ANSWER

You can't. Segues is available only in a storyboards. You have to do your navigation manually in -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];
}