【问题标题】:Detect a touch on a certain object in Xcode在 Xcode 中检测对某个对象的触摸
【发布时间】:2012-01-16 13:08:45
【问题描述】:

这个伪代码的 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)touchesBeganmethod 尝试过,它可以检测到触摸,但我无法使其特定于对象。谢谢

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

【问题讨论】:

  • 在用户按下控件之后显示提示有什么意义?
  • 提醒他必须选择什么单位。

标签: ios xcode cocoa-touch touch


【解决方案1】:

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

- (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:做同样的事情

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-23
    • 2014-12-07
    • 1970-01-01
    • 1970-01-01
    • 2019-01-10
    • 1970-01-01
    • 2011-06-17
    相关资源
    最近更新 更多