更新时间:2022-04-29 01:09:31
如果您想在 5 分钟后锁定手机,请执行以下操作:
设置这个:[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
并设置一个计时器:[NSTimer scheduleTimerWithTimeInterval:240 target:self selector:@selector(disableIdleTimer) userInfo:nil repeats:NO];
在 disableIdleTimer 方法中,您将设置:[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
If you would like to lock the phone after 5 minutes then do the following:
set this: [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
and also set a timer: [NSTimer scheduledTimerWithTimeInterval:240 target:self selector:@selector(disableIdleTimer) userInfo:nil repeats:NO];
And in the disableIdleTimer method you will set this: [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
这将适用于以下条件:iPhone 的自动锁定功能设置为最低(1 分钟).
This will work with the following condition: the iPhone's autolock function is set to the minimum (1 minute).
正如我目前所见,没有更好的方法.
As I see in the moment, there is no better method.