标签:
1.超链接显示
_richTextView.editable = NO; // 不可编辑
_richTextView.dataDetectorTypes = UIDataDetectorTypeAll; // 自动识别超链接,电话等
// 点击超链接的代理
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange {
NSString *strUrl = [URL absoluteString];
// TODO:
return NO; // 筛选,返回YES会用sari浏览器打开
}
2.禁止弹出菜单
// 不添加手势会弹出菜单,
- (void)addLongPressAction { // 添加长按手势会掩盖原有手势
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
[_richTextView addGestureRecognizer:longPress]; // 添加手势,默认0.5秒
}
// 手势相应
- (void)longPress:(UILongPressGestureRecognizer *)gestureRecognizer {
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) { // 响应点下的一次
// ToastShow(@"作者已禁止复制文本");
}
}
3.定制菜单
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if(action == @selector(cut:))
{
return YES; // 需要的选项返回YES
}
return NO; // 过滤掉
}
标签:
原文地址:http://my.oschina.net/littleDog/blog/497033