ios - UIPopoverPresentationController fails on iPad -


i trying implement uipopoverpresentationcontroller in app display tableviewcontroller. works fine when app runs on iphone crashes on ipad.

the code problem is:

    - (void)soundsbuttonhandler:(uibarbuttonitem *)barbuttonitem {      iesoundstableviewcontroller *soundstvc = (iesoundstableviewcontroller *)[storyboard instantiateviewcontrollerwithidentifier:@"soundstableviewcontroller"];      soundstvc.basesceneviewcontroller = self;      soundstvc.popoverpresentationcontroller = [[uipopoverpresentationcontroller alloc] initwithpresentedviewcontroller:soundstvc presentingviewcontroller:self];         soundstvc.modalpresentationstyle = uimodalpresentationpopover;      [self presentviewcontroller:soundstvc animated:yes completion:nil];        self.popoverpresentationcontroller = soundstvc.popoverpresentationcontroller;      self.popoverpresentationcontroller.permittedarrowdirections = uipopoverarrowdirectionany;      self.popoverpresentationcontroller.barbuttonitem = barbuttonitem; } 

this works fine on iphone & brings tableview modally usual vertical presentation.

however, fails on ipad following stack trace:

- objc_exception_throw () - -[uipopoverpresentationcontroller presentationtransitionwillbegin] () - __71-[uipresentationcontroller _initviewhierarchyforpresentationsuperview:]_block_invoke () - __56-[uipresentationcontroller runtransitionforcurrentstate]_block_invoke () - _applyblocktocfarraycopiedtostack () - _aftercacommithandler () - __cfrunloop_is_calling_out_to_an_observer_callback_function__ () - __cfrunloopdoobservers () - __cfrunlooprun () - cfrunlooprunspecific () - gseventrunmodal () - uiapplicationmain () 

i've tried several variations of code ordering & using sourceview & sourcerect instead of barbuttonitem popover anchor, none of them help.

thanks.

you have use below code this..

   if (ui_user_interface_idiom() == uiuserinterfaceidiomphone) {         [self presentviewcontroller:activityviewcontroller animated:yes completion:nil];     }     //if ipad     else {         // change rect position popover         uipopovercontroller *popup = [[uipopovercontroller alloc] initwithcontentviewcontroller:activityviewcontroller];         [popup presentpopoverfromrect:yourrectwhatever  inview:self.view permittedarrowdirections:uipopoverarrowdirectiondown animated:yes];     } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -