The difference between IOS Uialertview and Uiactionsheet

Source: Internet
Author: User

The difference between Uialertview and Uiactionsheet:

1. Different frame positions:

Uialertview bullet box displayed in the middle

Uiactionsheet Bullet box appears at the bottom

2. Can I input the text box (reference: http://www.ithao123.cn/content-9409772.html)

Uialertview can be implemented, and Uiactionsheet cannot be implemented.

#import"RootViewController.h"@interfaceRootviewcontroller ()@end@implementationrootviewcontroller-(void) Viewdidload {[Super Viewdidload];Create a button click to show a bullet boxUIButton *button = [UIButton Buttonwithtype: (Uibuttontypecustom)]; button. frame = CGRectMake (100,100,100,100);Add a click method to the Button [button addTarget:Self action:@selector (Actionbutton:) forControlEvents: (UIControlEventTouchUpInside)]; button. backgroundcolor = [Uicolor Bluecolor]; [Self. View Addsubview:button];}Button's click Method-(void) Actionbutton: (UIButton *) button{Initializes a single UialertcontrollerParameter Preferredstyle: is the Ialertcontroller styleUialertcontrollerstylealert created equivalent to UialertviewUialertcontrollerstyleactionsheet created equivalent to uiactionsheet uialertcontroller *alertcontroller = [UIAlertController alertcontrollerwithtitle:@"Hint" message:@"Static" Preferredstyle: (Uialertcontrollerstylealert)];Create button Uialertaction *okaction = [Uialertaction actionwithtitle:@OK style: (Uialertactionstyledefault) handler:^ (uialertaction *action) {NSLog (@"Pay attention to study"); }];Create buttonNote the Cancel button can only add one uialertaction *cancelaction = [Uialertaction actionwithtitle:@"Cancel" style: (Uialertactionstylecancel) handler:^ (uialertaction *action) {Click on the button after the method directly in here to writeNSLog (@"Pay attention to study"); }];Create a warning buttonUialertaction *structlaction = [uialertaction actionwithtitle:@ "Warning" style: (uialertactionstyledestructive) handler : ^ (uialertaction *action) {NSLog (@ "Pay attention to learning");// }];//Add a button to add a button to the Uialertcontroller object [Alertcontroller addaction:okaction]; [Alertcontroller addaction:cancelaction];//[alertcontroller Addaction:structlaction]; The text box can be added only in alert cases [Alertcontroller addtextfieldwithconfigurationhandler:^ (Uitextfield *textfield) { TextField. placeholder = @"username"; TextField. securetextentry = YES;}]; //// Remove text //Uitextfield *text = alertController.textFields.firstObject;  Uialertaction *action = AlertController.actions.firstObject; //Uialertcontroller mode is equivalent to Uialertview Show method [Selfpresentviewcontroller:alertcontroller animated:  YES completion:nil];}            



The difference between IOS Uialertview and Uiactionsheet

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.