【发布时间】:2016-06-23 18:08:37
【问题描述】:
我想限制用户在UIWebView 中复制和共享文本。
我使用的代码是
- (void)viewDidLoad {
[super viewDidLoad];
self.webview.delegate = self;
NSString *path = [[NSBundle mainBundle] pathForResource:@"SampleHTML" ofType:@"html"];
NSString *htmlContent = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
[self.webview loadHTMLString:htmlContent baseURL:[NSURL URLWithString:@""]];
// Do any additional setup after loading the view, typically from a nib.
}
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if (action == @selector(copy:))
return NO;
else if (action == @selector(select:))
return YES;
return [super canPerformAction:action withSender:sender];
}
【问题讨论】:
标签: ios uiwebview selection copy-paste