Martin
Martin

Reputation: 2863

Can I change View to the ViewController when click the TableViewCell?

I am new to Objective-C.

It has TableViewCell and the TableView on the ViewController like the following picture.

enter image description here

I want to change the View to another Viewcontroller when I click the TableViewCell.

But it seems can not use the performSegueWithIdentifier to change the View in didSelectRowAtIndexPath without using UINavigationController , The error log like the following:

Push segues can only be used when the source controller is managed by an instance of UINavigationController.'

Is there has another way to change the View to another Viewcontroller when I click on the TableViewCell ?

Thanks in advance.

Upvotes: 0

Views: 45

Answers (2)

Michal
Michal

Reputation: 15669

In Interface Builder(storyboard) click the following:

enter image description here

Exactly what the debugger says: Push segues can only be used when the source controller is managed by an instance of UINavigationController.' Then you'll be able to push segues.

Upvotes: 1

Shaik Mohaideen
Shaik Mohaideen

Reputation: 31

U can present view controller using this

 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
    yourViewController *vc = [[yourViewController alloc]initWithNibName:@"yourViewController" bundle:[NSBundle mainBundle] ];  
        [self presentViewController:vc animated:YES completion:nil];

    }

Upvotes: 1

Related Questions