2

我有这个代码:

-(void)applicationDidBecomeActive:(UIApplication *)application {
JUnlockController *passcodeView = [[JUnlockController alloc] init];
[self.navigationController presentModalViewController:passcodeView animated:YES];
}

问题是,当我在我的应用程序中打开一个模态视图控制器时,它不会出现在它上面。我希望能够找出用户正在查看的当前视图控制器,所以我可以将它显示在上面。

4

2 回答 2

3

代替:

[self.navigationController presentModalViewController:passcodeView animated:YES];

利用:

[self presentModalViewController:passcodeView animated:YES];
于 2012-07-16T14:00:22.607 回答
2

如果您的应用程序仅由该导航控制器导航,您可以询问哪个 viewController 可见:

[self.navigationController.visibleViewController presentModalViewController:passcodeView animated:YES];

或者你可以利用UIApplicationDidBecomeActiveNotification让你的所有视图控制器扩展一个自定义类,该类在 ; 上viewWillAppear注册并取消注册viewWillDissapear;并在您的自定义基类中实现显示模式的回调。

编辑注意,这假设您self.navigationController在您的应用程序委托中有一个(您设置的)。您可能需要使用类似的东西self.window.rootViewController

于 2012-07-16T13:57:13.573 回答