auto-lock iphone/ipad programmatically

自作多情 提交于 2019-12-23 19:42:59

问题


Is there a way to 'force' the user to have auto-lock (and maybe passcode lock) on while the application is running (for security reasons mainly)? If we can't set them programmatically, can we at least check to see if they are set?

Thanks, Mihai


回答1:


if ([UIApplication sharedApplication].idleTimerDisabled == YES) {
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Please enable auto-lock"...];
    [alert show];
    [alert release];
} else {
    /* some code */
}

The above snippet will check to see if the idle timer is disabled. If it is, it will tell the user to enable it via a UIAlertView.




回答2:


YOu can use a Session handler class which inherits from UIApplication and fix a timer.. Thats very easy and fully customizable.



来源:https://stackoverflow.com/questions/3319044/auto-lock-iphone-ipad-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!