【发布时间】:2012-12-24 11:45:35
【问题描述】:
我没有可编辑的 UITextView。当我双击它时,我需要为其设置背景颜色。我怎样才能做到这一点?我认为不会发生 didbeginediting 事件,因为此 UITextView 不可编辑
【问题讨论】:
我没有可编辑的 UITextView。当我双击它时,我需要为其设置背景颜色。我怎样才能做到这一点?我认为不会发生 didbeginediting 事件,因为此 UITextView 不可编辑
【问题讨论】:
请使用Tap Gesture 来实现您的描述功能。
使用下面的代码在您的 TextView 中添加点按手势。
UITapGestureRecognizer* tapGestureObj = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(TapMethod:)];
tapGestureObj.numberOfTapsRequired = 2;
[textViewObj addGestureRecognizer:tapGestureObj];
TapMethod
-(void)TapMethod:(UITapGestureRecognizer*)gesture
{
//Set your logic on double tap of TextView...
}
【讨论】:
您可以将点击手势添加到文本视图中,您只需设置 numberoftapsrequired = 2 然后在手势识别器方法中您更改 bg 颜色还设置 userInteractionEnabled = yes
【讨论】: