1, the frame appears in the middle of the screen position
Uialertcontroller *alert = [Uialertcontroller alertcontrollerwithtitle:@"Tips"Message@"whether to exit"Preferredstyle:uialertcontrollerstylealert]; [Alert addaction:[uialertaction Actionwithtitle:@"Cancel"Style:uialertactionstylecancel Handler:nil]]; [Alert addaction:[uialertaction Actionwithtitle:@"Confirm"Style:uialertactionstyledestructive handler:^ (Uialertaction *_nonnull Action) { //What to do when you click Confirm }]]; [Self Presentviewcontroller:alert animated:yes completion:nil]; //Note that you must write this sentence, otherwise it will not show
This method can add a text box, enter the content
[Alert addtextfieldwithconfigurationhandler:^ (Uitextfield * _nonnull TextField) { @ " Please enter a name "; }]; [Alert Addtextfieldwithconfigurationhandler:^ (Uitextfield * _nonnull TextField) { @ " Please enter the price " ; }];
2, the frame appears at the bottom of the screen ( two different ways of the code is the first line of the last, the bottom is Uialertcontrollerstyleactionsheet)
1Uialertcontroller *alert = [Uialertcontroller alertcontrollerwithtitle:@"Tips"Message@"whether to exit"Preferredstyle:uialertcontrollerstyleactionsheet]; 2[Alert addaction:[uialertaction Actionwithtitle:@"Cancel"Style:uialertactionstylecancel Handler:nil]];3[Alert addaction:[uialertaction Actionwithtitle:@"Confirm"Style:uialertactionstyledestructive handler:^ (Uialertaction *_nonnull Action) {4 //What to do when you click Confirm5 }]];6[Self Presentviewcontroller:alert animated:yes completion:nil];//Note that you must write this sentence
Self-learning iOS development small function Three: the two ways of the frame (iOS8.3 after the new way, previously deprecated)