iphone - UIPopoverController is showing on the other button -
when uibutton tapped display uipopovercontroller, showing on other uibarbuttonitemand showing blank black opaque uipopovercontroller.
here implemented code:
- (ibaction)buttontapped:(id)sender { uibutton *btnaction; bookmarkviewcontroller* bookmarkvc = [[bookmarkviewcontroller alloc] init]; _buttonpopovercontroller = [[uipopovercontroller alloc] initwithcontentviewcontroller:bookmarkvc]; _buttonpopovercontroller.delegate = self; cgrect popoverframe = btnaction.frame; [_buttonpopovercontroller setpopovercontentsize:cgsizemake(320, 355) animated:no]; //only required if using delegate methods [_buttonpopovercontroller presentpopoverfromrect:popoverframe inview:self.view permittedarrowdirections:uipopoverarrowdirectionup animated:yes]; }
you missing assing sender btnaction
that uibutton *btnaction=(uibutton *)sender;
try this,
- (ibaction)buttontapped:(id)sender { uibutton *btnaction=(uibutton *)sender; uistoryboard *storyboard = [uistoryboard storyboardwithname:@"mainstoryboard" bundle:nil]; uiviewcontroller *bookmarkvc = [storyboard instantiateviewcontrollerwithidentifier:@"bookmarkviewcontroller"]; _buttonpopovercontroller = [[uipopovercontroller alloc] initwithcontentviewcontroller:bookmarkvc]; _buttonpopovercontroller.delegate = self; cgrect popoverframe = btnaction.frame; [bookmarkvc setcontentsizeforviewinpopover:cgsizemake(320, 355)]; //only required if using delegate methods [_buttonpopovercontroller presentpopoverfromrect:popoverframe inview:self.view permittedarrowdirections:uipopoverarrowdirectionup animated:yes]; }
Comments
Post a Comment