0

我没有可编辑的 UITextView。当我双击它时,我需要为其设置背景颜色。我怎样才能做到这一点?我认为不会发生 didbeginediting 事件,因为此 UITextView 不可编辑

4

2 回答 2

2

请使用Tap Gesture来实现您的描述功能。

  • 使用下面的代码在TextView中添加 Tap Gesture 。

    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...
    }
    
于 2012-12-24T11:53:57.970 回答
1

您可以将点击手势添加到文本视图,您只需设置 numberoftapsrequired = 2 然后在手势识别器方法中更改 bg 颜色还设置 userInteractionEnabled = yes

于 2012-12-24T11:52:59.077 回答