It is possible to use an existing ViewController with PerformSegueWithIdentifier?

后端 未结 7 1366
一整个雨季
一整个雨季 2020-12-31 05:32

I use the method performSegueWithIdentifier:sender: to open a new ViewController from a storyboard-file programmatically. This works like a charm.<

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-31 05:40

    Firstly you would be going against Apple's design in Using Segues: "A segue always presents a new view controller".

    To understand why it might help to know that what a segue does is create a new view controller and then the perform calls either showViewController or showDetailViewController depending on what kind of segue it is. So if you have an existing view controller just call those methods! e.g.

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
        Event *object = [self.fetchedResultsController objectAtIndexPath:indexPath];
        self.detailViewController.detailItem = object;
        [self showDetailViewController:self.detailViewController.navigationController sender:self];
    }
    

提交回复
热议问题