Skip to content
Browse files

add support of UITabMenuItem from Toolbar

  • Loading branch information...
1 parent b666e8f commit e2e0ce72adf624153297e210b47f0200c16eb2f3 @bsorrentino committed Mar 30, 2012
Showing with 34 additions and 1 deletion.
  1. +4 −0 Classes/Popover/WEPopoverController.h
  2. +30 −1 Classes/Popover/WEPopoverController.m
View
4 Classes/Popover/WEPopoverController.h
@@ -51,6 +51,10 @@
- (void)dismissPopoverAnimated:(BOOL)animated;
+- (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)item toolBar:(UIToolbar *)toolBar
+ permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections
+ animated:(BOOL)animated;
+
- (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)item
permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections
animated:(BOOL)animated;
View
31 Classes/Popover/WEPopoverController.m
@@ -1,4 +1,4 @@
-//
+ //
// WEPopoverController.m
// WEPopover
//
@@ -105,6 +105,35 @@ - (void)dismissPopoverAnimated:(BOOL)animated {
[self dismissPopoverAnimated:animated userInitiated:NO];
}
+- (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)item toolBar:(UIToolbar *)toolBar
+ permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections
+ animated:(BOOL)animated
+{
+
+ UIView *v = [self keyView];
+ UIButton *button = nil;
+
+ for (UIView *subview in toolBar.subviews)
+ {
+ if ([[subview class].description isEqualToString:@"UIToolbarButton"])
+ {
+ for (id target in [(UIButton *)subview allTargets])
+ {
+ if (target == item)
+ {
+ button = (UIButton *)subview;
+ break;
+ }
+ }
+ if (button != nil) break;
+ }
+ }
+
+ CGRect rect = [button.superview convertRect:button.frame toView:v];
+
+ [self presentPopoverFromRect:rect inView:v permittedArrowDirections:arrowDirections animated:animated];
+}
+
- (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)item
permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections
animated:(BOOL)animated {

0 comments on commit e2e0ce7

Please sign in to comment.
Something went wrong with that request. Please try again.