applicationDidBecomeActive get called when iPhone's Lock Screen button is pressed

138 views Asked by At

In my app , I check [UIPasteboard generalPasteboard].changeCount in

- (void)applicationDidBecomeActive:(UIApplication *)application

But I found that every time I press iPhone's Lock Screen button , this applicationDidBecomeActive will be called , and the changeCount value will alway be 0 this time

Why the applicationDidBecomeActive called for Lock Screen ? (My OS version is iOS16.1)

1

There are 1 answers

0
ximmyxiao On

In my situation , I use this code to avoid the paste board check in locking screen(In fact ,the pasteboardChangeCount will be zero when applicationDidBecomeActive is called in Lock Screen )

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