我有 UIWebView 用于显示文章 HTML 页面。我使用 UILongGesture 来显示 UIMenuController。在 UIMenuItem 中有一个关于注释的字段。如果单击注意它会显示 UITextView。但是如果我在 UITextView 中长按,UIMenuItem 会显示。如何隐藏?
- (void)viewDidLoad
{
NSMutableArray *items = [[[UIMenuController sharedMenuController] menuItems] mutableCopy];
if (!items) items = [[NSMutableArray alloc] init];
UIMenuItem *menuItem;
menuItem = [[UIMenuItem alloc] initWithTitle:@"BookMark" action:@selector(book:)];
[items addObject:menuItem];
[menuItem release];
menuItem = [[UIMenuItem alloc] initWithTitle:@"Notes" action:@selector(note:)];
[items addObject:menuItem];
[menuItem release];
[[UIMenuController sharedMenuController] setMenuItems:items];
[items release];
UILongPressGestureRecognizer *tap = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(tapTest:)];
[tap setDelegate:self];
[wbCont.scrollView addGestureRecognizer:tap];
wbCont.userInteractionEnabled=YES;
[self.view addSubview:wbCont];
}
如果使用点击注意:
- (void)note:(id)sender {
NSLog(@"Note");
// wbCont.userInteractionEnabled=NO;
if ([UIMenuController sharedMenuController]) {
[UIMenuController sharedMenuController].menuVisible = NO;
}
txtview = [[UITextView alloc]initWithFrame:CGRectMake(0,0,320,568)];
txtview.font = [UIFont fontWithName:@"Helvetica" size:12];
txtview.font = [UIFont boldSystemFontOfSize:12];
txtview.backgroundColor = [UIColor whiteColor];
txtview.scrollEnabled = YES;
txtview.pagingEnabled = YES;
txtview.editable = YES;
txtview.tag = mainTag*10000;
[self.view addSubview:txtview];
}