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