检测 Xcode 中某个对象的触摸

发布于 2024-12-27 04:07:25 字数 374 浏览 0 评论 0原文

这个伪代码的 Xcode 代码是什么?

if ([Any UIPickerView in my ViewController isTouched]) {
    [AnyUIView setHidden:NO];
}

if ([Any UIPickerView in my ViewController is__NOT__Touched__Anymore__]) {
    [AnyUIView setHidden:YES];
}

尝试使用 -(void)touchesBegan 方法,它检测到触摸,但我无法使其特定于对象。谢谢

​我想在触摸 UIPickerView 时在显示屏上显示提示。

What's the Xcode code for this pseudocode?

if ([Any UIPickerView in my ViewController isTouched]) {
    [AnyUIView setHidden:NO];
}

if ([Any UIPickerView in my ViewController is__NOT__Touched__Anymore__]) {
    [AnyUIView setHidden:YES];
}

Tried it with the -(void)touchesBeganmethod, it detects the touches but I was not able to make it object-specific. Thanks

P.S. I want to display a hint on the display while the UIPickerViewis touched.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吾性傲以野 2025-01-03 04:07:25

这只是我的想法......但你应该能够明白......

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [super touchesBegan:touches withEvent:event];
    UITouch *touch = [touches anyObject];
    if ([touch.view isKindOfClass: UIPickerView.class]) {
         //your touch was in a uipickerview ... do whatever you have to do
    }
}

并用 touchesEnded:withEvent: 做同样的事情

This is just from the top of my head...... but you should be able to get the idea...

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [super touchesBegan:touches withEvent:event];
    UITouch *touch = [touches anyObject];
    if ([touch.view isKindOfClass: UIPickerView.class]) {
         //your touch was in a uipickerview ... do whatever you have to do
    }
}

..and do the same with touchesEnded:withEvent:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文