在iPhone 3.0上如何禁用剪切,复制和粘贴选项

时间:2023-01-20 17:35:50

Does any one know, how can i disable cut, copy and paste option on iPhone 3.0?

有谁知道,我怎样才能在iPhone 3.0上禁用剪切,复制和粘贴选项?

Thanks for your help and time.

谢谢你的帮助和时间。

3 个解决方案

#1


I, too, couldn't find much documentation on using canPerformAction:withSender: for this purpose. So, I settled for clearing the pasteboard when exiting the application. In my AppDelegate.m:

我也找不到很多关于使用canPerformAction的文档:withSender:为此目的。因此,我决定在退出应用程序时清除粘贴板。在我的AppDelegate.m中:

- (void)applicationWillTerminate:(UIApplication *)application {

  NSLog(@"application terminating");

  // Clear pasteboard to prevent pasting into other applications:
  UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
  pasteBoard.items = nil;

}

This worked well for my user-annotated reference application. I don't mind users copying and pasting within my application, but I'd rather they not republish my original content.

这适用于我的用户注释的参考应用程序。我不介意用户在我的应用程序中复制和粘贴,但我宁愿他们不重新发布我的原始内容。

At some point I'd like more fine-grained control, perhaps with canPerformAction:withSender:, so that I can allow users to copy/paste the content they do create themselves.

在某些时候,我想要更精细的控制,也许使用canPerformAction:withSender:,这样我就可以允许用户复制/粘贴他们自己创建的内容。

#2


Override this method in the controller class.

在控制器类中重写此方法。

// Hide cut/copy/paste menu

//隐藏剪切/复制/粘贴菜单

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

    if ( [UIMenuController sharedMenuController] )
    {
        [UIMenuController sharedMenuController].menuVisible = NO;

    }
    return NO;  
}

#3


Any responder (UIView or UIWindow subclass) can override the canPerformAction:withSender: method, so you could just return NO for all the actions you don't want to permit.

任何响应者(UIView或UIWindow子类)都可以覆盖canPerformAction:withSender:方法,因此您可以为您不想允许的所有操作返回NO。

See the UIResponder documentation...

查看UIResponder文档......

#1


I, too, couldn't find much documentation on using canPerformAction:withSender: for this purpose. So, I settled for clearing the pasteboard when exiting the application. In my AppDelegate.m:

我也找不到很多关于使用canPerformAction的文档:withSender:为此目的。因此,我决定在退出应用程序时清除粘贴板。在我的AppDelegate.m中:

- (void)applicationWillTerminate:(UIApplication *)application {

  NSLog(@"application terminating");

  // Clear pasteboard to prevent pasting into other applications:
  UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
  pasteBoard.items = nil;

}

This worked well for my user-annotated reference application. I don't mind users copying and pasting within my application, but I'd rather they not republish my original content.

这适用于我的用户注释的参考应用程序。我不介意用户在我的应用程序中复制和粘贴,但我宁愿他们不重新发布我的原始内容。

At some point I'd like more fine-grained control, perhaps with canPerformAction:withSender:, so that I can allow users to copy/paste the content they do create themselves.

在某些时候,我想要更精细的控制,也许使用canPerformAction:withSender:,这样我就可以允许用户复制/粘贴他们自己创建的内容。

#2


Override this method in the controller class.

在控制器类中重写此方法。

// Hide cut/copy/paste menu

//隐藏剪切/复制/粘贴菜单

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

    if ( [UIMenuController sharedMenuController] )
    {
        [UIMenuController sharedMenuController].menuVisible = NO;

    }
    return NO;  
}

#3


Any responder (UIView or UIWindow subclass) can override the canPerformAction:withSender: method, so you could just return NO for all the actions you don't want to permit.

任何响应者(UIView或UIWindow子类)都可以覆盖canPerformAction:withSender:方法,因此您可以为您不想允许的所有操作返回NO。

See the UIResponder documentation...

查看UIResponder文档......