获取程序中无需释放的ViewController

时间:2023-03-09 17:25:57
获取程序中无需释放的ViewController

AppDelegate.h

@property (strong, nonatomic) UIViewController *viewController;

在需要用的地方

#define appDelegate ((AppDelegate *)[UIApplication sharedApplication].delegate)

if (!appDelegate.viewController) {

appDelegate.viewController =[ [UIViewController alloc]init]

}

[self presentViewController:appDelegate.viewController animated:YES completion:^{

}];

相关文章