ios - popoverControllerDidDismissPopover NOT doing what I think it should -
so, think when click outside of popover, method popovercontrollerdiddismisspopover
should called. know isn't called when dismisspopoveranimated
called.
i have simple project have setup shows popovercontrollerdiddismisspopover
isn't called:
#import "viewcontroller.h" #import "popoverviewcontroller.h" @interface viewcontroller () { popoverviewcontroller *controller; uipopovercontroller *popovercontroller; } @end @implementation viewcontroller @synthesize button; - (ibaction)showpopover:(uibutton *)sender { if ([popovercontroller ispopovervisible]) { [popovercontroller dismisspopoveranimated:yes]; } else { cgrect poprect = cgrectmake(self.button.frame.origin.x, self.button.frame.origin.y, self.button.frame.size.width, self.button.frame.size.height); [popovercontroller presentpopoverfromrect:poprect inview:self.view permittedarrowdirections:uipopoverarrowdirectionany animated:yes]; } } - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. controller = [[popoverviewcontroller alloc] initwithnibname:@"popoverviewcontroller" bundle:nil]; popovercontroller = [[uipopovercontroller alloc] initwithcontentviewcontroller:controller]; } - (void)viewdidunload { [super viewdidunload]; // release retained subviews of main view. } - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { return yes; } - (void)popovercontrollerdiddismisspopover:(uipopovercontroller *)popovercontroller { nslog(@"why never called!!!!"); } - (bool)popovercontrollershoulddismisspopover:(uipopovercontroller *)popovercontroller { return true; } @end
please tell me i'm going wrong or how can detect when popover dismissed.
the whole project here:
you never set delegate
popovercontroller
self
.
_popovercontroller.delegate = self;
Comments
Post a Comment