Can we lock the app while app goes to sleep mode in IPhone?

后端 未结 4 1995
耶瑟儿~
耶瑟儿~ 2021-02-11 11:18

I am working an app where lock option is included.My app starts with passcode screen.If I enter correct code then it navigates to next screen.If I dont use the app for long time

4条回答
  •  轮回少年
    2021-02-11 11:38

    I have developed same type of apps, where I have implemented this things, For this I made a one Class like this

    @interface CommonUIClass:NSObject
    
    +(void)setCurrentViewController:(id)controller;
    
    +(void)openPassWordProtectedScreen;
    
    @end
    

    And

    @implementation CommonUIClass
    
    static id currentViewControllerObj;
    
    +(void)setCurrentViewController:(id)controller{ 
    
      currentViewControllerObj = controller;
    
    }
    
    +(void)openPassWordProtectedScreen{
    
    PROTECTED_CONTROLLER *view = [[PROTECTED_CONTROLLER alloc]init];
    
    
    
    if ([currentViewControllerObj respondsToSelector:@selector(presentModalViewController:animated:)]) {
            [currentViewControllerObj presentModalViewController:patternLock animated:NO];
    }
    
    }
    
    
    @end
    

    Just import this class to every ViewController And put this code to

    -(void)viewWillApear{
    
    [CommonUIClass setCurrentViewController:self];
    [super viewWillApear];
    }
    

    And When Application Goes in Background

    -(void)applicationWillResignActive:(UIApplication *)application{
    
    [CommonUIClass openPassWordProtectedScreen];
    
    }
    

    Thanks..

提交回复
热议问题