Display a view or splash screen before applicationDidEnterBackground (to avoid active view screenshot)

后端 未结 8 789
小鲜肉
小鲜肉 2020-11-27 15:40

I have confidential informations in my app, so I would like to hide them with a splash screen when the app is about to be moved to background.

I do run the app on iO

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 15:48

    Need to write the code as follows:

    -(void)applicationWillResignActive:(UIApplication *)application
    {
        imageView = [[UIImageView alloc]initWithFrame:[self.window frame]];
        [imageView setImage:[UIImage imageNamed:@"Portrait(768x1024).png"]];
        [self.window addSubview:imageView];
    }
    

    Here to remove the imageview:

    - (void)applicationDidBecomeActive:(UIApplication *)application
    {
        if(imageView != nil) {
            [imageView removeFromSuperview];
            imageView = nil;
        }
    }
    

    It is working and properly tested.

提交回复
热议问题