Skip to content

Commit 623bdd7

Browse files
committed
Adding an option ‘completion’ block parameter to popover presentation.
1 parent 6af87b2 commit 623bdd7

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

WYPopoverController/WYPopoverController.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,18 @@ typedef NS_OPTIONS(NSUInteger, WYPopoverAnimationOptions) {
112112

113113
- (void)presentPopoverAsDialogAnimated:(BOOL)animated;
114114

115+
- (void)presentPopoverFromRect:(CGRect)aRect
116+
inView:(UIView *)aView
117+
permittedArrowDirections:(WYPopoverArrowDirection)arrowDirections
118+
animated:(BOOL)aAnimated
119+
options:(WYPopoverAnimationOptions)aOptions;
120+
115121
- (void)presentPopoverFromRect:(CGRect)rect
116122
inView:(UIView *)view
117123
permittedArrowDirections:(WYPopoverArrowDirection)arrowDirections
118124
animated:(BOOL)animated
119-
options:(WYPopoverAnimationOptions)options;
125+
options:(WYPopoverAnimationOptions)options
126+
completion:(void (^)(void))completion;
120127

121128
- (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)item
122129
permittedArrowDirections:(WYPopoverArrowDirection)arrowDirections

WYPopoverController/WYPopoverController.m

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,11 +1548,31 @@ - (void)presentPopoverAsDialogAnimated:(BOOL)aAnimated
15481548
options:WYPopoverAnimationOptionFade];
15491549
}
15501550

1551+
1552+
- (void)presentPopoverFromRect:(CGRect)aRect
1553+
inView:(UIView *)aView
1554+
permittedArrowDirections:(WYPopoverArrowDirection)arrowDirections
1555+
animated:(BOOL)aAnimated
1556+
options:(WYPopoverAnimationOptions)aOptions
1557+
{
1558+
[self presentPopoverFromRect:aRect
1559+
inView:aView
1560+
permittedArrowDirections:arrowDirections
1561+
animated:aAnimated
1562+
options:aOptions
1563+
completion:nil];
1564+
}
1565+
1566+
1567+
// Hsoi 2014-01-24 - Added the 'completion' parameter: adding the parameter, the invocation
1568+
// of it, and the compatiblity version of this method that lacks the 'completion' parameter
1569+
// so existing code can function without change.
15511570
- (void)presentPopoverFromRect:(CGRect)aRect
15521571
inView:(UIView *)aView
15531572
permittedArrowDirections:(WYPopoverArrowDirection)arrowDirections
15541573
animated:(BOOL)aAnimated
15551574
options:(WYPopoverAnimationOptions)aOptions
1575+
completion:(void (^)(void))completion
15561576
{
15571577
NSAssert((arrowDirections != WYPopoverArrowDirectionUnknown), @"WYPopoverArrowDirection must not be UNKNOWN");
15581578

@@ -1650,6 +1670,11 @@ - (void)presentPopoverFromRect:(CGRect)aRect
16501670
{
16511671
[self->viewController viewDidAppear:YES];
16521672
}
1673+
1674+
if (completion)
1675+
{
1676+
completion();
1677+
}
16531678
}];
16541679
}
16551680
else
@@ -1660,6 +1685,11 @@ - (void)presentPopoverFromRect:(CGRect)aRect
16601685
{
16611686
[viewController viewDidAppear:NO];
16621687
}
1688+
1689+
if (completion)
1690+
{
1691+
completion();
1692+
}
16631693
}
16641694

16651695
if (isListeningNotifications == NO)

0 commit comments

Comments
 (0)