IOS development-do not enter the standby mode (screen stay awake)-UIApplication Learning

Source: Internet
Author: User

If you do not want the iPhone to enter the lock wait status when the application is running, add the following line of code:


[[UIApplication sharedApplication] setIdleTimerDisabled: YES];
By the way, I learned UIApplication.
The iPhone application is started by the main function, which calls UIApplicationMainFunction in the following format:
Align with UIApplicationMain, option + mouse click. To view.


So what did the UIApplicationMain function do? This function is mainly responsible for three things:

1) initialize the application object from the given class name, that is, initializing an instance of the UIApplication or subclass object. If you specify nil here, the system will default to the UIApplication class, this class controls and coordinates the running of applications. In subsequent work, you can use the static sharedApplication method to obtain the application handle.

2) Initialize an application delegate from the given application delegate class. Set the delegate as the delegate of the application. If the input parameter is nil, the system calls the function to access the Info. plist file to find the main nib file and obtain the application delegate.

3) Start the main event loop and start to receive events.
The above is the work of the UIApplicationMain function. The next question is how to display and control messages in the application view? Below is UIApplication <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> Export/Ig1d/X08Dgo6m21M/export/Cw + a8uLz + export + z/export/7z6K1xMS/seq21M/export + export/N0LbUz/release/export/Export YsK8/rvy1d/J + sP81tzG2r/Y1sbKwrz + records/records + PGJyIC8 + records/records + SjrMv80rK/records + dPQtcSy2df3o6y2vL/records + bOrLuk0rvQ QbK7v8m4/pushed + 8 + pushed/y74beiy83P + 8 + pushed/N0L/pushed + qt6LV38/r0qq1xLav1/pushed/N0MDgoaO2 + pushed/pushed Uf2zzLXEyfrD/MrCvP6ho8/Cw + bLtcP3zq/N0Nb30qq/ydLUsOzExNCpysLH6aO6IDxiciAvPjxzdHJvbmc + response/Response CHBsaWNhdGlvbsu1w/ejurWx06bTw7PM0PLI67vutq/xtmys1rtq0kos1ek491_vuo4 + snPw + bEx7j2t723qM/queues + queues Samples/samples/bKx7G7tffTw6Oszaizo8rH08PAtLGjtObK/Samples Example/etcTE2rTmo6zI57n7zqrTptPDs8zQ8rfWxeTBy8yrtuDE2rTmstnX98 + example/J0tTU2tXiwO + 9 + example/Example Alibaba/yvavSqrHku6/Alibaba Logs/8re9z/logs BnRhdGlvbilvbGRTdGF0dXNCYXJPcmllbnRhdGlvbsu1w/ejurWxU3RhdHVzQmFyv/K3vc/examples/ejurWxU3RhdHVzQmFyv/examples/Examples Examples/examples + G199PDzq/N0MDgtcRhcHBsaWNhdGlvbldpbGxSZXNpZ25BY3RpdmUoKbe9ILeoo6y2 + examples/Examples T723qKOstvi1scbBxLuxu73iy/i1xMqxuvKjrNPWu + logs/c/ItffTw86vzdDA4LXEIGFwcGxpY2F0aW9uRGlkUmVjZWl2ZU1lbW9yeVdh Cm5pbmcoKbe9t6i + export + uvPL/export/fPtc2zx7/export/Cw + export/J6NbD1ve958PmaWNvbsnPtcTK/Export Examples/samples/K1srGo6zKx7fx1qez1nJlZG8gdW5kb7LZ1/samples + zzNDy1MvQ0Ne0zKyjrNTaMi4w Warning = "program in running state");} 4. Prevent the screen from going down to sleep state // prevent the screen from going down with caution. The default value is no 2.0 [UIApplication sharedApplication]. idleTimerDisabled = YES Use this function with caution because it consumes a lot of power. 5. display networking status // display networking tag 2.0 [UIApplication sharedApplication]. networkActivityIndicatorVisible = YES; 6. display an address NSString * addressText = @ "1 Infinite Loop, Cupertino, CA 95014"; // URL encode the spaces addressText = [addressText encoding: NSASCIIStringEncoding] on map; NSString * urlText = [NSString stringWithFormat: @ "http://maps.google.com/maps? Q = % @ ", addressText]; [[UIApplication sharedApplication] openURL: [NSURLURLWithString: urlText]; 7. Send email NSString * recipients = @" mailto: first@example.com? Cc = second@example.com & subject = Hello from California! "; NSString * body = @" & body = It is raining in sunny California! "; NSString * email = [NSString stringWithFormat: @" % @ ", recipients, body]; email = [email token: NSUTF8StringEncoding]; [[UIApplication sharedApplication] openURL: [NSURLURLWithString: email]; 8. call a number // Call Google 411 [[[UIApplication sharedApplication] openURL: [NSURLURLWithString: @ "tel: // 8004664411"]; 9. send SMS // Text to Google sms [[[UIApplication sharedApplication] openURL: [NSURLURLWithString: @ "SMS: // 466453"]; 10. open a URL // Lanuch any iPhone developers fav site [[UIApplication sharedApplication] openURL: [NSURLURLWithString: @ "http://itunesconnect.apple.com"];

Related Article

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.