获取程序中无需释放的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:^{

    }];

posted @ 2015-08-20 10:34  菜鸟程序猿  阅读(205)  评论(0编辑  收藏  举报