首页 > 代码库 > iOS双击home键之后应用程序显示一张图片,保护应用程序隐私

iOS双击home键之后应用程序显示一张图片,保护应用程序隐私

源代码下载地址:http://download.csdn.net/detail/haogaoming123/8417041


类似于支付宝项目,在双击home键之后应用程序进入后台程序,然后这时候将应用程序页面隐藏,然后显示一样默认图片

 //   After didFinish addObserver  accept Notification
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(userDidTakeScreenshot) name:UIApplicationDidEnterBackgroundNotification object:nil];

- (void)userDidTakeScreenshot
{
    
    self.lockView = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    UIImage *image = [UIImage imageNamed:@"Personal_logo.jpg"];
    self.lockView.image = image;
    [self.window addSubview:self.lockView];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    
    //  进入前台移除视图
    
    if (self.lockView)
    {
        [self.lockView removeFromSuperview];
        self.lockView = nil;
    }
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


iOS双击home键之后应用程序显示一张图片,保护应用程序隐私