I have UIWebView for displaying some articles. I need to select some text from UIWebView and use bookmark. So i'm using selection = [wbCont stringByEvaluatingJavaScriptFromString:@"window.getSelection().toString()"];
But when i longpress the UIMenuItem displays with copy,define. I read some doc and used canPerformAction:
copy NO. But still it displaying.
- (void)viewDidLoad
{
[wbCont loadHTMLString:webString baseURL:nil];
[self.view addSubview:wbCont];
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:@"Note" action:@selector(note:)];
[items addObject:menuItem];
[menuItem release];
[[UIMenuController sharedMenuController] setMenuItems:items];
[items release];
}
- (BOOL) canPerformAction:(SEL)action withSender:(id)sender
{
if (action == @selector(copy:))
{
return NO;
}
if (action == @selector(book:))
{
return YES;
}
else if (action == @selector(note:))
{
return YES;
}
return [super canPerformAction:action withSender:sender];
}