I'm trying to add a menu controller as a quick choice of options after tapping my tab bar, however I don't get the arrow, when I use
menuCont.arrowDirection = UIMenuControllerArrowDown;
But if I use Up, Left or Right it works fine.
Can someone else try this and advise ?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
if ([touch tapCount] == 2) {
[self becomeFirstResponder];
UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:@"Blue" action:@selector(blueView)];
UIMenuItem *menuItem2 = [[UIMenuItem alloc] initWithTitle:@"Green" action:@selector(greenView)];
UIMenuItem *menuItem3 = [[UIMenuItem alloc] initWithTitle:@"Red" action:@selector(redView)];
UIMenuController *menuCont = [UIMenuController sharedMenuController];
[menuCont setTargetRect:CGRectMake(0,0,320,200) inView:self.view];
menuCont.menuItems = [NSArray arrayWithObjects:menuItem, menuItem2, menuItem3, nil];
menuCont.arrowDirection = UIMenuControllerArrowDown;
[menuCont setMenuVisible:YES animated:YES];
}
}
- (void)blueView {
self.view.backgroundColor = [UIColor blueColor];
}
- (void)greenView {
self.view.backgroundColor = [UIColor greenColor];
}
- (void)redView {
self.view.backgroundColor = [UIColor redColor];
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
BOOL answer = NO;
if (action == @selector(blueView))
answer = YES;
if (action == @selector(greenView))
answer = YES;
if (action == @selector(redView))
answer = YES;
return answer;
}
- (BOOL)canBecomeFirstResponder {
return YES;
}
PS. I'm wondering if its old school, as it doesn't auto-complete when entering some of the menu controller code ?