我有一个以导航控制器开头的应用程序。这个导航控制器可以打开模态视图控制器:
- (void)openModalController:(id)sender
{
[self performSegueWithIdentifier:@"SegueIdentifier"];
}
但是当用户使用 url 方案打开应用程序时,我想展示打开模式控制器的应用程序。所以我添加了一些方法并尝试了:
// Controller
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated]; // animated == NO in initial loading
if (_shouldOpenModalController) {
[self openModalController:nil];
}
}
- (void)setShouldOpenModalController:(BOOL)flag
{
_shouldOpenModalController = flag;
}
// AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (launchOptions) {
UINavigationController *nc = (UINavigationController *)self.window.rootViewController;
MyViewController *c = (MyViewController *)[ns topViewController];
[c setShouldOpenModalController];
}
}
但这里有一个问题:openModalController:
我在情节提要中设置的过渡动画执行转场。没有动画怎么办?这项任务还有另一种方法吗?