我的应用程序代表有一个RootViewController *viewController;该应用程序是用这个视图启动的。
从现在开始,当用户导航到应用程序中的不同功能时,我将继续显示模态视图(最多3层)。
我已经设置了应用程序来接收推送通知,并且我在应用程序委托中有didReceiveRemoteNotification来检索有效负载。
现在的问题是:
发布于 2011-10-24 07:37:52
没有通用的内置方法来做这件事。最好的解决方案可能是将一个属性添加到您的应用程序委托中,在那里可以存储它。
@property (nonatomic, retain) UIViewController *currentModalViewController;当您呈现模态视图控制器时,请执行以下操作:
#import "MyAppDelegate.h"
// ....
MyAppDelegate *appDelegate = (MyAppDelegate *)[UIApplication sharedApplication].delegate;
appDelegate.currentModalViewController = vc;
[self presentModalViewController:vc animated:YES];您还需要确保在退出时丢失引用:
[self dismissModalViewControllerAimated:YES];
MyAppDelegate *appDelegate = (MyAppDelegate *)[UIApplication sharedApplication].delegate;
appDelegate.currentModalViewController = nil;然后,在您的应用程序委托,您有您需要的一切,以取消当前的模态视图控制器,并检查是否有一个模态视图控制器存在的时候。
https://stackoverflow.com/questions/7872238
复制相似问题