3

I know this is one of the most FAQs. As a matter of fact, I found the link below:

Disabling user selection in UIWebView

but I still can't remove the copy and define items from the menu selection. I just want my 'Quick' and 'Another' item to show in the menu. Can any one show me a way? Thank you for your time. Here is my code and screenshot.

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{


    if (action == @selector(quick:)) {

        NSLog(@"my quick view");
        return YES;

    }else if (action == @selector(another:)){

        NSLog(@"my another view");
        return YES;

    }else if (action == @selector(copy:) ||
        action == @selector(paste:)||
        action == @selector(cut:) ||
        action == @selector(define:) )
    {
        return NO;
    }

    return [super canPerformAction:action withSender:sender];

}

enter image description here

Community
  • 1
  • 1
boochan224
  • 371
  • 1
  • 5
  • 13

2 Answers2

1

First of all, to fix your problem, change define: to _define: to remove the relating option.

However, _define: is a function in Apple's private API (because of _), you can't use them in your product if you want to release them on App Store.

However, in terms of your copy: option, your canPerformAction should remove it.

FYI, here I attach a list of private API functions, which canPerformAction will call:

_promptForReplace:

_showTextStyleOptions:

_define:

_addShortcut:

_accessibilitySpeak:

_accessibilitySpeakLanguageSelection:

_accessibilityPauseSpeaking:

Therefore, if you want to remove any function above, you have to create a customized menu bar. This video below should help you do the trick:

http://www.youtube.com/watch?v=SB7w8JEJSrc

GOOD LUCK!

EDIT:

Here is your solution:

-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{


if (action == @selector(quick:)) {

    NSLog(@"my quick view");
    return YES;

}else if (action == @selector(another:)){

    NSLog(@"my another view");
    return YES;

}

return NO;

}
donkey
  • 4,285
  • 7
  • 42
  • 68
  • Here's the API calls I got when viewing a PDF: - Action is: cut: - Action is: select: - Action is: selectAll: - Action is: paste: - Action is: delete: - Action is: _promptForReplace: - Action is: _showTextStyleOptions: - Action is: _addShortcut: - Action is: _accessibilitySpeak: - Action is: _accessibilitySpeakLanguageSelection: - Action is: _accessibilityPauseSpeaking: - Action is: makeTextWritingDirectionRightToLeft: - Action is: makeTextWritingDirectionLeftToRight: – cynistersix Dec 12 '13 at 21:28
  • Basically, you are prohibited to include ANY private API, which starts their name with an underscore `_`. If you happen to have them as part of your code, it will be certainly rejected by App Store. – donkey Dec 12 '13 at 22:00
  • APPLE's own private APIs, more precisely – donkey Dec 12 '13 at 22:08
0

Try to use this one in this method .....

-(void)webViewDidFinishLoad:(UIWebView *)theWebView
{
    [webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none'; document.body.style.KhtmlUserSelect='none'"];
}

I hope it helps you...

Dharmbir Singh
  • 17,485
  • 5
  • 50
  • 66
  • Thanks for your advice, but this kills the whole thing. I want my items 'Quick' and 'Another' to show up, disabling the copy and define. – boochan224 Aug 24 '13 at 01:26