IOS Lock Screen judgment

Source: Internet
Author: User
<span id="Label3"></p><p class="p1"><p class="p1"><span class="s1">IOS Lock Screen judgment</span></p></p><p class="p2"><p class="p2"><span class="s1"></span></p></p><p class="p1"><p class="p1"><span class="s1">An object in the Application's Singleton class object that gets the application delegate</span></p></p><p class="p1"><p class="p1"><span class="s1">uiapplicationdelegate* mydelegate = [[uiapplication sharedapplication] delegate];</span></p></p><p class="p2"><p class="p2"><span class="s1"></span></p></p><p class="p1"><p class="p1"><span class="s1">UIApplication receives all system events and lifecycle events, it passes the event to Uiapplicationdelegate for processing, and for the user input event, it is passed to the corresponding target object to be Processed.</span></p></p><p class="p2"><p class="p2"><span class="s1"></span></p></p><p class="p1"><p class="p1"><span class="s1">-(void) applicationwillresignactive: (uiapplication *) Application</span></p></p><p class="p1"><p class="p1"><span class="s1">Notifies the delegate that the application will go into an inactive state during which the application does not receive messages or Events.</span></p></p><p class="p1"><p class="p1"><span class="s1">This method is also called when the user locks the Screen.</span></p></p><p class="p2"><p class="p2"><span class="s1"></span></p></p><p class="p1"><p class="p1"><span class="s1">It adapts to the delegate method when the application is re-opened by the User. Another common use is an out-of-memory system warning that invokes the Applicationdidreceivememorywarning () method of the Application's delegate class, and then we can try to free up some memory.</span></p></p><p class="p2"><p class="p2"><span class="s1"></span></p></p><p class="p2"><p class="p2"><span class="s1"></span></p></p><p class="p1"><p class="p1"><span class="s1">Cfnotificationcenteraddobserver (cfnotificationcentergetdarwinnotifycenter (), NULL, updateenabled, CFSTR (" Com.apple.iokit.hid.displayStatus "), NULL, cfnotificationsuspensionbehaviordeliverimmediately);</span></p></p><p class="p1"><p class="p1"><span class="s1"></span></p></p><p class="p1"><p class="p1"><span class="s1">1 status</span></p></p><p class="p1"><p class="p1"><span class="s1">Cfnotificationcenteraddobserver (cfnotificationcentergetdarwinnotifycenter (), NULL, lockcomplete, CFSTR (" Com.apple.springboard.lockcomplete "), NULL, cfnotificationsuspensionbehaviordeliverimmediately);</span></p></p><p class="p1"><p class="p1"><span class="s1">2 status</span></p></p><p class="p1"><p class="p1"><span class="s1">Cfnotificationcenteraddobserver (cfnotificationcentergetdarwinnotifycenter (), NULL, lockstate, CFSTR (" Com.apple.springboard.lockstate "), NULL, cfnotificationsuspensionbehaviordeliverimmediately);</span></p></p><p class="p2"><p class="p2"><span class="s1"></span></p></p><p class="p2"><p class="p2"><span class="s1"></span></p></p><p class="p1"><p class="p1"><span class="s1">static void updateenabled (cfnotificationcenterref center, void* observer, cfstringref name, const void* object, cfdiction Aryref UserInfo) {</span></p></p><p class="p1"><p class="p1"><span class="s1">uint64_t state;</span></p></p><p class="p1"><p class="p1"><span class="s1">int token;</span></p></p><p class="p1"><p class="p1"><span class="s1">Notify_register_check ("com.apple.iokit.hid.displayStatus", &token);</span></p></p><p class="p1"><p class="p1"><span class="s1">Notify_get_state (token, &state);</span></p></p><p class="p1"><p class="p1"><span class="s1">Notify_cancel (token);</span></p></p><p class="p1"><p class="p1"><span class="s1">NSLog (@ "lock Screen status:%llu", state);</span></p></p><p class="p1"><p class="p1"><span class="s1">}</span></p></p><p class="p2"><p class="p2"><span class="s1"></span></p></p><p class="p1"><p class="p1"><span class="s1">static void Lockcomplete (cfnotificationcenterref center, void* observer, cfstringref name, const void* object, Cfdictiona Ryref UserInfo) {</span></p></p><p class="p1"><p class="p1"><span class="s1">uint64_t state;</span></p></p><p class="p1"><p class="p1"><span class="s1">int token;</span></p></p><p class="p1"><p class="p1"><span class="s1">Notify_register_check ("com.apple.springboard.lockcomplete", &token);</span></p></p><p class="p1"><p class="p1"><span class="s1">Notify_get_state (token, &state);</span></p></p><p class="p1"><p class="p1"><span class="s1">Notify_cancel (token);</span></p></p><p class="p1"><p class="p1"><span class="s1">NSLog (@ "lockcomplete status:%llu", state);</span></p></p><p class="p1"><p class="p1"><span class="s1">}</span></p></p><p class="p2"><p class="p2"><span class="s1"></span></p></p><p class="p1"><p class="p1"><span class="s1">static void Lockstate (cfnotificationcenterref center, void* observer, cfstringref name, const void* object, cfdictionaryr EF UserInfo) {</span></p></p><p class="p1"><p class="p1"><span class="s1">uint64_t state;</span></p></p><p class="p1"><p class="p1"><span class="s1">int token;</span></p></p><p class="p1"><p class="p1"><span class="s1">Notify_register_check ("com.apple.springboard.lockstate", &token);</span></p></p><p class="p1"><p class="p1"><span class="s1">Notify_get_state (token, &state);</span></p></p><p class="p1"><p class="p1"><span class="s1">Notify_cancel (token);</span></p></p><p class="p1"><p class="p1"><span class="s1">NSLog (@ "lockstate status:%llu", state);</span></p></p><p class="p1"><p class="p1"><span class="s1">}</span></p></p><p><p>IOS Lock Screen judgment</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.