如何在UITextView中禁用放大 [英] How to disable magnification in UITextView
本文介绍了如何在UITextView中禁用放大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想摆脱UITextView中的放大和文本选择,但是我需要电话号码,链接和地址检测器.我正在使用
I want to get rid of magnification and text selection in UITextView but I need phone number, link and address detectors. I am using
-(void)addGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer {
if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) {
gestureRecognizer.enabled = NO;
}
[super addGestureRecognizer:gestureRecognizer];
return;}
停止放大,但同时也停止选择textview检测到的选择电话号码/地址/链接.
如果执行[_txtView setSelectable:NO];
,它将同时停止放大和文本选择以及数据检测.
to stop magnification, but it also stops selection phone number / address / link detected by textview.
If I do [_txtView setSelectable:NO];
it stops both magnification and text selection as well as data detection.
推荐答案
将图像放在.xib文件中的UITextview上,然后放在下面的代码中.
Put image on your UITextview in .xib file then put below code.
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBarHidden = YES;
UITapGestureRecognizer *tappress= [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(longPressed:)];
img.userInteractionEnabled = YES;
[img addGestureRecognizer:tappress];
}
-(void)longPressed:(UILongPressGestureRecognizer *)sender
{
[yourtextview becomeFirstResponder];
}
在我的代码img中是UIImageview
in my code img is a UIImageview
这篇关于如何在UITextView中禁用放大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文