ios applicationDidBecomeActive在iPhone的锁屏按钮被按下时被调用

yftpprvb  于 2022-12-05  发布在  iOS
关注(0)|答案(1)|浏览(148)

在我的应用程序中,我签入[UIPasteboard generalPasteboard].changeCount

- (void)applicationDidBecomeActive:(UIApplication *)application

但是我发现每次我按下iPhone的锁屏按钮,都会调用这个applicationDidBecomeActive,而这次changeCount的值总是0
为什么applicationDidBecomeActive要求锁屏?(我的操作系统版本是iOS16.1)

c86crjj0

c86crjj01#

在我的情况下,我使用这段代码来避免在锁屏中进行粘贴板检查(事实上,在锁屏中调用applicationDidBecomeActive时,pasteboardChangeCount将为零)

- (void)checkPasteBoard
{
    static NSInteger lastCount = 0;
    NSInteger pasteboardChangeCount = [UIPasteboard generalPasteboard].changeCount;
    if (lastCount != pasteboardChangeCount && pasteboardChangeCount != 0)
    {
        lastCount = pasteboardChangeCount;
    }
    else
    {
        return;
    }

相关问题