HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios如何使UITextView检测一下?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    NSLog(@"touchesBegan");

    //test
    UITouch *touch = [event allTouches] anyObject];
    if ([touch tapCount] == 2) {
        NSLog (@"tapcount 2");
        [self.textview becomeFirstResponder];

    }   

     else if ([touch tapCount] == 1) {
         NSLog (@"tapcount 1");
         [self.textview becomeFirstResponder];
         [self.view performSELEctor:@SELEctor(SELEct:)];


     }

}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
    [super touchesBegan:touches withEvent:event];
    NSLog(@"touchesMoved");
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
    NSLog(@"****touchesEnded");
    [self.nextResponder touchesEnded: touches withEvent:event]; 
    NSLog(@"****touchesEnded");
    [super touchesEnded:touches withEvent:event];
    NSLog(@"****touchesEnded");
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
    [super touchesCancelled:touches withEvent:event]; 
    NSLog(@"touchesCancelled");
}

我的问题:

我想在UITextView上点击一次即可模拟两个水龙头,这是该代码中的textview.但是当我在textview上点击一次或两次时,我只能从一个和两个水龙头得到NSLog,只有在外面.我应该怎么做才能使它工作?

解决方法

可能我会在这里使用两个 gesture recognizers.
//..@L_480_5@me stuff above here probably in you're controllers viewDidLoad

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@SELEctor(singleTapRecognized:)];
singleTap.numberOfTapsrequired = 1;
[someTextView addGestureRecognizer:singleTap];
[singleTap release];

UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@SELEctor(doubleTapRecognized:)];
doubleTap.numberOfTapsrequired = 2;
[someTextView addGestureRecognizer:doubleTap];
[doubleTap release];

选择器就像:

- (void)singleTapRecognized:(UIGestureRecognizer *)gestureRecognizer {
    NSLog(@"single tap");
    // ...etc
}

- (void)doubleTapRecognized:(UIGestureRecognizer *)gestureRecognizer {
    NSLog(@"double tap");
    // ...etc
}

大佬总结

以上是大佬教程为你收集整理的ios如何使UITextView检测一下?全部内容,希望文章能够帮你解决ios如何使UITextView检测一下?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。