gpt4 book ai didi

ios - 检测 Xcode 中某个对象的触摸

转载 作者:行者123 更新时间:2023-11-29 04:50:50 25 4
gpt4 key购买 nike

此伪代码的 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 时在显示屏上显示提示。

最佳答案

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

- (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:

执行相同操作

关于ios - 检测 Xcode 中某个对象的触摸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8880462/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com