Reputation: 2309
I'm trying to display a lock screen on the launch of my app.
I'm trying to use the code here -> https://github.com/jazzychad/CPLockController
I tried to trigger the lock screen in the viewDidLoad function, but the modal screen never launched. I also unsuccessfully tried to trigger the lock in the application delegate didFinishLaunchingWithOptions function.
Can anyone help me out?
Upvotes: 1
Views: 1975
Reputation: 834
You may also want to present your lock screen on applicationWillEnterForeground for the sake of fast app switching.
Upvotes: 3
Reputation: 2309
This was a silly question. I wasn't fully understanding delegates.
I'm providing the answer for people that happen to stumble upon this.
First be sure to add the #import "CPLockController.h" and then the CPLockControllerDelegate to the application delegate header.
@interface SampleAppAppDelegate : NSObject <UIApplicationDelegate, CPLockControllerDelegate> {
Then in the applicationDidFinishLaunching function, launch the modal using the view controller.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after app launch
[window addSubview:viewController.view];
CPLockController *lockController = [[CPLockController alloc]initWithStyle:CPLockControllerTypeAuth];
lockController.passcode = @"1234";
lockController.delegate = self;
lockController.title = @"Passcode is 1234";
lockController.modalPresentationStyle = UIModalPresentationFormSheet;
[viewController presentModalViewController:lockController animated:NO];
[window makeKeyAndVisible];
}
Upvotes: 2