在模拟器上,我看到UIMenucontroller没有问题,但在运行iOs 4+的设备上测试时不会显示出来。它是使用IB添加的标准uitextview。
我已经将这些方法添加到了代理的视图控制器中,但我不认为它们是必要的,因为我想要标准的menucontroller、select、copy等。更不用说它们没有被调用。
谢谢你的帮助
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
NSLog(@"Can perform action called");
BOOL answer = NO;
if (action == @selector(copy:))
{
answer = YES;
}
if (action == @selector(cut:))
{
answer = YES;
}
if (action == @selector(paste:))
{
answer = YES;
}
if (action == @selector(select:))
{
answer = YES;
}
if (action == @selector(selectAll:))
{
answer = YES;
}
return answer;
}
- (BOOL) canBecomeFirstResponder {
NSLog(@"can become first called");
return YES;
}发布于 2011-07-07 05:09:10
您需要添加一个手势识别器,或覆盖触摸method :withEvent:方法,并显示菜单控制器:
//Assumes you assigned a CGRect for where the menu should appear to theRect
UIMenuController *mc = [UIMenuController sharedMenuController];
[mc setTargetRect:theRect inView:self];
[mc setMenuVisible:YES animated:YES];你也可以should override the methods -copy,-cut,-paste等。
https://stackoverflow.com/questions/6601940
复制相似问题