Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Classes/Popover/WEPopoverController.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

@protocol WEPopoverControllerDelegate<NSObject>

@optional

- (void)popoverControllerDidDismissPopover:(WEPopoverController *)popoverController;
- (BOOL)popoverControllerShouldDismissPopover:(WEPopoverController *)popoverController;

Expand Down
13 changes: 10 additions & 3 deletions Classes/Popover/WEPopoverController.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished c

if (userInitiatedDismissal) {
//Only send message to delegate in case the user initiated this event, which is if he touched outside the view
[delegate popoverControllerDidDismissPopover:self];
if(delegate != nil && [delegate conformsToProtocol:@protocol(WEPopoverControllerDelegate)] &&
[delegate respondsToSelector:@selector(popoverControllerDidDismissPopover:)]) {
[delegate popoverControllerDidDismissPopover:self];
}
}
}
}
Expand Down Expand Up @@ -246,9 +249,13 @@ - (void)repositionPopoverFromRect:(CGRect)rect

- (void)viewWasTouched:(WETouchableView *)view {
if (popoverVisible) {
if (!delegate || [delegate popoverControllerShouldDismissPopover:self]) {
[self dismissPopoverAnimated:YES userInitiated:YES];
BOOL shouldDismiss = YES;
if(delegate != nil && [delegate conformsToProtocol:@protocol(WEPopoverControllerDelegate)] &&
[delegate respondsToSelector:@selector(popoverControllerShouldDismissPopover:)]) {
shouldDismiss = [delegate popoverControllerShouldDismissPopover:self];
}
if(shouldDismiss)
[self dismissPopoverAnimated:YES userInitiated:YES];
}
}

Expand Down