nicolaschengdev / WYPopoverController

WYPopoverController is for the presentation of content in popover on iPhone / iPad devices. Very customizable.
Other
1.94k stars 370 forks source link

addObserver: forKeyPath: exc_bad_access #144

Open DenDoronin opened 10 years ago

DenDoronin commented 10 years ago

Hi, I'm getting this error on the next case:

  1. i show popover on button press, where i used presentPopoverFromRect: inView: permittedArrowDirections: animated:
  2. dissmiss popover with [self.customPopoverController dismissPopoverAnimated:YES]; self.customPopoverController = nil;
  3. if i open and than close popover for many times (just click button as faster as i can), it crushes on addObserver method

full method's code:

sammcewan commented 10 years ago

This should be fixed in the fork I'm maintaining.

On Tue, Oct 21, 2014 at 8:09 PM, DenDoronin notifications@github.com wrote:

Hi, I'm getting this error on the next case:

  1. i show popover on button press, where i used presentPopoverFromRect: inView: permittedArrowDirections: animated:
  2. dissmiss popover with [self.customPopoverController dismissPopoverAnimated:YES]; self.customPopoverController = nil;
  3. if i open and than close popover for many times (just click button as faster as i can), it crushes on addObserver method full method's code:

    • (void)showPopoverWithControllerByStroryBoardName: (NSString) name fromView: (UIView) view delegate: (id) delegate permittedArrowDirections:(WYPopoverArrowDirection)aArrowDirections withContext:(id) context{

    if (!self.customPopoverController) { UIViewController *contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:name]; if (!self.storyboard) { // init from nib contentViewController = [[UIViewController alloc] initWithNibName:name bundle:nil]; }

    if (context && [contentViewController respondsToSelector:NSSelectorFromString(@"model")])
        [contentViewController setValue:context forKeyPath:@"model"];
    
    if ( [contentViewController respondsToSelector:NSSelectorFromString(@"delegate")])
        [contentViewController setValue:self forKeyPath:@"delegate"];
    
    self.customPopoverController = [[WYPopoverController alloc] initWithContentViewController:contentViewController];
    
    if (self.popoverContentSizeHeight > 0 && self.popoverContentSizeWidth >0)
        self.customPopoverController.popoverContentSize = CGSizeMake(self.popoverContentSizeWidth, self.popoverContentSizeHeight);
    
    self.customPopoverController.delegate = delegate;
    self.customPopoverController.theme.fillTopColor = [UIColor whiteColor];
    self.customPopoverController.theme.outerShadowColor = [UIColor darkGrayColor];
    self.customPopoverController.theme.outerShadowBlurRadius = 6.0;
    self.customPopoverController.theme.outerCornerRadius = 4.0;
    self.customPopoverController.theme.innerCornerRadius = 2.0;
    self.customPopoverController.theme.borderWidth = 0.0;
    [self.customPopoverController presentPopoverFromRect:view.bounds
                                                  inView:view
                                permittedArrowDirections:aArrowDirections
                                                animated:YES];

    } else { [self.customPopoverController dismissPopoverAnimated:YES]; self.customPopoverController = nil; }

    }

    Reply to this email directly or view it on GitHub: https://github.com/nicolaschengdev/WYPopoverController/issues/144

DenDoronin commented 10 years ago

great, thanks!