I'm creating an application that uses the UIMenuController (at least that's what I think it's called). It's that little bubble that look like the Cut, Copy, Paste bubble when tapping on text. This is what I've got so far:
Code:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
if ([touch tapCount] == 2) {
[self becomeFirstResponder];
UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:@"1" action:@selector(one)];
UIMenuItem *menuItem2 = [[UIMenuItem alloc] initWithTitle:@"2" action:@selector(two)];
UIMenuController *menuCont = [UIMenuController sharedMenuController];
[menuCont setTargetRect:CGRectMake(0, 0, 92, 310) inView:self.view];
menuCont.menuItems = [NSArray arrayWithObjects:menuItem, menuItem2, nil];
[menuCont setMenuVisible:YES animated:YES];
}
}
-(void)one {
my stuff here;
}
-(void)two {
other stuff here;
}
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender {
BOOL answer = NO;
if (action == @selector(one))
answer = YES;
if (action == @selector(two))
answer = YES;
return answer;
}
-(BOOL)canBecomeFirstResponder {
return YES;
}
So, what I want to do is make the UIMenu thingy show up only when the user double taps on imageView1 (the UIImageView). I think I have to do something with this...
Code:
UITouch *touch = [[event allTouches] anyObject];
... but I'm not sure. So what do I change or add? Thanks.