How to perform Segue in AppDelegate?

前端 未结 3 2055
广开言路
广开言路 2021-02-20 06:28

I am trying to complete an application on IOS 5.1 with Storyboard. Basically I am doing a dropbox app. Since I am using Dropbox SDK link to Dropbox is handled in AppDelegate.m.

3条回答
  •  别跟我提以往
    2021-02-20 06:41

    You can do it like this:

    UINavigationController *navigationController = (UINavigationController*) self.window.rootViewController;
    
    [[[navigationController viewControllers] objectAtIndex:0] performSegueWithIdentifier:@"goToMeeting" sender:self];
    

    This will only work if the index in viewControllers array matches the one of your view controller and if it exists of course. In this case is the first one (in the array and storyboard).

    The segue ("goToMeeting") must not be attached to an action. The way you do this is by control-dragging from the file owner icon at the bottom of the storyboard scene to the destination scene. A popup will appear that will ask for an option in “Manual Segue”; pick “Push” as the type. Tap on the little square and make sure you’re in the Attributes Inspector. Give it an identifier which you will use to refer to it in code.

提交回复
热议问题