iPhone [self performseguewithidentifier… ] is not showing the new view controller

邮差的信 提交于 2019-12-25 05:09:14

问题


I have been all over stackoverflow and all over Google and I cannot seem to figure this one out. Here's my scenario:

I have my app's "main screen" where the user first makes decisions about what they're going to do. The app works off of a CoreData database which is created by "importing" XML files. The user can choose to open an XML file attached to an email in my application, which automatically triggers my main screen to show up and run the import of the file.

I can get this far without any issues. In my storyboard, I have a segue called ParseSegue from my main screen to a view controller which will handle the parsing and give the user some status information.

When the main screen is called via the email app, the main screen automatically calls

[self performSegueWithIdentifier:@"ParseSegue" sender:self];

I then check for this segue name in prepareForSegue and it's a valid name. This is where I assign the file URL to the parser controller so that it can parse the correct file.

The problem is that the segue never actually happens. The prepareForSegue method gets called, the name "ParseSegue" can be checked against and is valid, but the segue itself simply does not happen. If I add a button to the main screen and tell it to perform the segue within the storyboard, it works fine. But calling it programmatically seems to do nothing.


回答1:


It turns out that I was looking in the wrong place entirely. My problem was that in my appDelegate, where the app reacts to the incoming URL, I was inadvertently creating a new instance of my storyboard and my main view controller. This was different than the one which was already active and may or may not have been on the screen.

The controller I was creating was never actually shown. I only noticed this because the log:

NSLog(@"Source: %@", [segue.sourceViewController description]);

would show different memory addresses for my test (the button push) and the import test. This led me to believe that I was, in fact, working with two different instances of the storyboard and the app's main view controller. Thanks to Paul for the suggestion of logging the destination and the source controllers.



来源:https://stackoverflow.com/questions/11083481/iphone-self-performseguewithidentifier-is-not-showing-the-new-view-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!