cocoa touch - How to handle displaying of UIAlertView iOS -
does uiview receive events when alert appears? there existing events lostfocus?
i know possible override show method of uialertview, wonder whether there approach handle directly top view of hierarchy?
i've had this, , it's huge pain.
put in view controller. (uialertview deprecated since release of ios 8)
uialertcontroller *somecontroller = [uialertcontroller alertcontrollerwithtitle:@"sometitle" message:@"somemessage" preferredstyle:uialertcontrollerstylealert]; uialertaction *someaction = [uialertaction actionwithtitle:@"sometitle" style:uialertactionstyledefault handler:^(uialertaction *action){ // code here action }]; [somecontroller addaction:someaction]; [self presentviewcontroller:somecontroller animated:yes completion:^{ // code here after alert presents }]; you may add many actions like. notes go over:
- the
alertcontroller'sstyleeitheruialertcontrollerstylealertif it'salert box, oruialertcontrollerstyleactionsheetif wantaction sheetbottom of screen. - the
blocksomeaction'shandlerparameter needs have parameteractionuialertaction*. - the
completionblocktakes no parameters, , called when alert presents. - the
hanlerblockcalled when user taps on choice in alert box or action sheet.
refer apple documentation more info uialertcontroller class or uialertaction class.
for more info objective-c blocks, visit fuckingblocksyntax.com, or more work-friendly counterpart, goshdarnblocksyntax.com.
Comments
Post a Comment