Skip to content

Commit 9b04d28

Browse files
Merge pull request #66 from barz/completion-block
adding popover completion block
2 parents 0f999c6 + 0e59989 commit 9b04d28

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

WYPopoverController/WYPopoverController.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ typedef NS_OPTIONS(NSUInteger, WYPopoverAnimationOptions) {
127127
animated:(BOOL)animated
128128
options:(WYPopoverAnimationOptions)options;
129129

130+
- (void)presentPopoverFromRect:(CGRect)rect
131+
inView:(UIView *)view
132+
permittedArrowDirections:(WYPopoverArrowDirection)arrowDirections
133+
animated:(BOOL)animated
134+
options:(WYPopoverAnimationOptions)options
135+
completion:(void (^)(void))completion;
136+
137+
130138
- (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)item
131139
permittedArrowDirections:(WYPopoverArrowDirection)arrowDirections
132140
animated:(BOOL)animated

WYPopoverController/WYPopoverController.m

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,21 @@ - (void)presentPopoverFromRect:(CGRect)aRect
15081508
permittedArrowDirections:(WYPopoverArrowDirection)arrowDirections
15091509
animated:(BOOL)aAnimated
15101510
options:(WYPopoverAnimationOptions)aOptions
1511+
{
1512+
[self presentPopoverFromRect:aRect
1513+
inView:aView
1514+
permittedArrowDirections:arrowDirections
1515+
animated:aAnimated
1516+
options:aOptions
1517+
completion:nil];
1518+
}
1519+
1520+
- (void)presentPopoverFromRect:(CGRect)aRect
1521+
inView:(UIView *)aView
1522+
permittedArrowDirections:(WYPopoverArrowDirection)arrowDirections
1523+
animated:(BOOL)aAnimated
1524+
options:(WYPopoverAnimationOptions)aOptions
1525+
completion:(void (^)(void))completion
15111526
{
15121527
NSAssert((arrowDirections != WYPopoverArrowDirectionUnknown), @"WYPopoverArrowDirection must not be UNKNOWN");
15131528

@@ -1609,6 +1624,11 @@ - (void)presentPopoverFromRect:(CGRect)aRect
16091624
{
16101625
[viewController viewDidAppear:YES];
16111626
}
1627+
1628+
if (completion)
1629+
{
1630+
completion();
1631+
}
16121632
}];
16131633
}
16141634
else
@@ -1619,6 +1639,11 @@ - (void)presentPopoverFromRect:(CGRect)aRect
16191639
{
16201640
[viewController viewDidAppear:NO];
16211641
}
1642+
1643+
if (completion)
1644+
{
1645+
completion();
1646+
}
16221647
}
16231648

16241649
if (isListeningNotifications == NO)

0 commit comments

Comments
 (0)