objective c - UIAlertAction can't be clicked on iPad -


i created uialertcontroller 3 uialertaction. working in iphone, cant click in of uialertaction's in ipad. working, , didn't made changes in code

uialertcontroller *alert = [uialertcontroller alertcontrollerwithtitle:@“select item” message:@“please choose 1.”                                                                  preferredstyle:uialertcontrollerstyleactionsheet];   [alert addaction:[uialertaction actionwithtitle:@"cancel" style:uialertactionstylecancel handler:^(uialertaction *action) {     _logoview.alpha = 1; }]];   uiwindow* window = [[uiwindow alloc] initwithframe:[uiscreen mainscreen].bounds]; window.rootviewcontroller = [uiviewcontroller new]; window.windowlevel = uiwindowlevelalert + 1;  nsstring *buttontitle = [sessionarray objectatindex:0];  uialertaction *session1 = [uialertaction actionwithtitle:buttontitle style:uialertactionstyledefault handler:^(uialertaction * _nonnull action)  {     window.hidden = yes;     [self sessionpickerselected:0]; }]; [alert addaction:session1];  buttontitle = [sessionarray objectatindex:1]; uialertaction *session2 = [uialertaction actionwithtitle:buttontitle style:uialertactionstyledefault handler:^(uialertaction * _nonnull action)  {     window.hidden = yes;     [self sessionpickerselected:1]; }]; [alert addaction:session2];  buttontitle = [sessionarray objectatindex:2]; uialertaction *session3 = [uialertaction actionwithtitle:buttontitle style:uialertactionstyledefault handler:^(uialertaction * _nonnull action)  {     window.hidden = yes;     [self sessionpickerselected:2];          }]; [alert addaction:session3];  [alert setmodalpresentationstyle:uimodalpresentationpopover];  uipopoverpresentationcontroller *poppresenter = [alert popoverpresentationcontroller]; poppresenter.sourceview = _btnlogin; poppresenter.sourcerect = _btnlogin.bounds;  [window makekeyandvisible]; [window.rootviewcontroller presentviewcontroller:alert animated:yes completion:nil]; 

in order work on ipad use following methods

- (void) actionselect:(uibutton *)sender {       uialertcontroller *alert = [uialertcontroller alertcontrollerwithtitle:@"confirm add photo"                                                                    message:@"are sure select photo?"                                                             preferredstyle:uialertcontrollerstyleactionsheet]; // 1        uialertaction *firstaction = [uialertaction actionwithtitle:@"take photo"                                                           style:uialertactionstyledefault handler:^(uialertaction * action) {                                                               nslog(@"you pressed invitation num ");                                                               [self dismissviewcontrolleranimated:yes completion:nil];                                                               [self takephoto:sender];                                                            }]; // 2     [alert addaction:firstaction]; // 4       uialertaction *secondaction = [uialertaction actionwithtitle:@"select photo"                                                            style:uialertactionstyledefault handler:^(uialertaction * action) {                                                                nslog(@"you pressed invitation num ");                                                                [self dismissviewcontrolleranimated:yes completion:nil];                                                                [self selectphoto:sender];                                                              }]; // 2     [alert addaction:secondaction]; // 4       uialertaction *thirdaction = [uialertaction actionwithtitle:@"cancel"                                                           style:uialertactionstylecancel handler:^(uialertaction * action) {                                                               nslog(@"you pressed cancel button ");                                                           }]; // 3       [alert addaction:thirdaction]; // 5       if ([utility isuserinterfaceipad]) {         // remove arrow action sheet.         [alert.popoverpresentationcontroller setpermittedarrowdirections:0];          //for set action sheet middle of view.         alert.popoverpresentationcontroller.sourceview = self.view;         alert.popoverpresentationcontroller.sourcerect = self.view.bounds;      }       [self presentviewcontroller:alert animated:yes completion:nil]; // 6   } 

to detect ipad

+ (bool)isuserinterfaceipad{      if (ui_user_interface_idiom() == uiuserinterfaceidiompad)     {         //do ur  ipad logic         return  yes;      }else     {         //do ur  iphone logic         return no;      }  } 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -