Reputation: 6465
HI, I am creating an App in which countdown will be running. I want to lock the iPhone when user taps on the button to start the countdown. Can anyone of you tell me how to do it. Any sample App or code will be very helpful.
here is the image which will make clear what I am asking for.
When I will slide the "lock" from left to right user will be ale to further interact with the App
Thanks in Advance!
Upvotes: 0
Views: 194
Reputation: 1803
You wont be able to stop the user from hitting the home button to 'close' your app, but locking the App itself is pretty straight forward.
Firstly, when a user hits 'lock', you can either hide the normal UI elements that allow user input & unhide the locking mechanism OR make the unlocking mechanism appear on another ViewController.
As for the unlocking mechanism itself, you could use a UISlider and implement something like
addTarget:self action:@selector(sliderMove:) forControlEvents:UIControlEventValueChanged
to see when a user changes the position.
If it reaches the maximum, then unlock & show your UI elements/remove from superview. If it doesn't reach the maximum, then set the value back to minimum with
setValue:position animated:YES
Alternatively you could put a UIImageView on the screen, catch the touch events and create your own slider, but that seems like more work than using the built in UISlider.
Upvotes: 4