Warning boxes and action sheets (iOS development)

Source: Internet
Author: User

Warning Box (Alertview) When modal, do not close it can not do other things, so not the following circumstances should not be used casually.

1. The application cannot continue running.

If there is not enough memory, there is no network. Generally, only one button is required.

2. Ask for another solution.

When not running, ask if you can use a 3G network.

3. Ask for authorization for the operation.

When it comes to accessing private information, user authorization, such as location, photo album, etc. is required.


The action table (ACTIONSHEET) can provide multiple choices to the user. You can use it to send a picture to a Sina Weibo or Facebook platform.

/implement uialertviewdelegate//This delegate is not actually used, just practice practiced hand, because the warning window has two buttons index//No for 0,yes (void) Alertview: (Uialertview *) Alertview Clickedbuttonatindex: (Nsinteger) buttonindex{NSLog (@ "Buttonindex =%li", (long) buttonindex);} Implementing uiactionsheetdelegate//This delegate also has no practical significance, that is, the Output command Window output pressed index number to achieve response-(void) Actionsheet: (Uiactionsheet *) Actionsheet Clickedbuttonatindex: (Nsinteger) buttonindex{NSLog (@ "Buttonindex =%li", (long) buttonindex);} -(Ibaction) Testalertview: (ID) Sender {//warning box described above//delegate parameter is used to set the warning window of the delegate object Uialertview *alertview = [[Uiale                                                Rtview alloc] initwithtitle:@ "alert" message: @ "Alert text goes Here"                                              Delegate:self cancelbuttontitle:@ "No"    otherbuttontitles:@ "Yes", nil];    [Alertview show];    }-(ibaction) Testactionsheet: (ID) Sender {//Cancelbuttontitle set Cancel title//Destructivebuttontile Set Destroy button, only one on top UiactiOnsheet *actionsheet = [[Uiactionsheet alloc] Initwithtitle:nil                                  Delegate:self cancelbuttontitle:@ "Cancel" destructivebuttontitle:@ "destructive button"    otherbuttontitles:@ "Sina Weibo", Nil];    Set to Automatic style Actionsheet.actionsheetstyle = uiactionsheetstyleautomatic; [Actionsheet ShowInView:self.view];}


Warning boxes and action sheets (iOS development)

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.