ios 按home键进入后台的触发处理

当用户不在于应用交互时(比如程序退出), 添加一个名为UIApplicationWillResignActiveNotification通知,调用通知方法applicationWillResignActive

 - (void)viewDidLoad

{

    ...

    UIApplication *app = [UIApplication sharedApplication];

    [[NSNotificationCenter defaultCenter]

     addObserver:self

     selector:@selector(applicationWillResignActive:)

     name:UIApplicationWillResignActiveNotification

     object:app];

}

- (void)applicationWillResignActive:(NSNotification *)notification 

{

}

你可能感兴趣的:(IOS)