Skip to content

Commit

Permalink
introduce a new interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthraim committed Jun 8, 2016
1 parent a95932a commit 987583b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ToolTipMenu/ToolTipMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,28 @@ - (dispatch_queue_t)methodQueue
[menuCont setMenuVisible:YES animated:YES];
}

RCT_EXPORT_METHOD(showFromRect:(nonnull NSNumber *)reactTag
items: (NSArray *)items
rect: (NSArray *)rectArr)
{
CGRect rect = CGRectMake([rectArr[0] floatValue], [rectArr[1] floatValue],
[rectArr[2] floatValue], [rectArr[3] floatValue]);
UIView *view = [self.bridge.uiManager viewForReactTag:reactTag];
NSArray *buttons = items;
NSMutableArray *menuItems = [NSMutableArray array];
for (NSString *buttonText in buttons) {
NSString *sel = [NSString stringWithFormat:@"magic_%@", buttonText];
[menuItems addObject:[[UIMenuItem alloc]
initWithTitle:buttonText
action:NSSelectorFromString(sel)]];
}
[view becomeFirstResponder];
UIMenuController *menuCont = [UIMenuController sharedMenuController];
view.superview.frame = rect;
[menuCont setTargetRect:view.frame inView:view.superview];
menuCont.arrowDirection = UIMenuControllerArrowDown;
menuCont.menuItems = menuItems;
[menuCont setMenuVisible:YES animated:YES];
}

@end

0 comments on commit 987583b

Please sign in to comment.