gpt4 book ai didi

ios - idleTimerDisabled 不适用于(自主)单一应用程序模式

转载 作者:行者123 更新时间:2023-11-28 23:33:06 25 4
gpt4 key购买 nike

我们有一个信息亭应用程序,我们在其中使用 idleTimerDisabled 来防止屏幕在工作时间关闭,并让它在晚上关闭。

我使用在 applicationDidBecomeActive 方法中创建的计时器执行此操作:

self.screenLockTimer = [NSTimer scheduledTimerWithTimeInterval:300 target:self selector:@selector(setupScreenLock) userInfo:nil repeats:YES];

-

- (void)setupScreenLock {
NSDate *currentDate = [NSDate date];
NSDate *closingDate = [[NSCalendar currentCalendar] dateBySettingHour:17 minute:0 second:0 ofDate:currentDate options:0];
BOOL isOpeningHours = [currentDate compare:closingDate] == NSOrderedAscending;
[UIApplication sharedApplication].idleTimerDisabled = isOpeningHours;
}

在我们开始使用Autonomous Single App Mode 之前,这曾经工作得很好。现在屏幕不再在晚上关闭。对此有解释(和解决方法)吗?我知道 iOS 12 中存在一个错误,其中 idleTimerDisabled 不再适用于引导访问,但我还没有看到关于单一应用模式的类似问题的报告。

最佳答案

触发 native 操作可能会“解决”问题。我能够使用下面的代码解决我的问题。

尝试使用以下代码:

    [UIApplication sharedApplication].idleTimerDisabled = isOpeningHours;

// Guided access idle timer fix
UITextField *textField = [[UITextField alloc] init];
[self.view addSubview:textField]; // self.view or whatever relevant view is accessible.
[textField becomeFirstResponder];
[textField resignFirstResponder];
[textField removeFromSuperView];

关于ios - idleTimerDisabled 不适用于(自主)单一应用程序模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55813336/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com