【问题标题】:Prevent UISegmentedControl from changing value with multitouch gestures防止 UISegmentedControl 使用多点触控手势更改值
【发布时间】:2013-09-07 04:58:56
【问题描述】:

我有一系列分段控件,它们在发生“值已更改”事件时调用方法。

我的问题是,如果用户执行从控件开始的多点触控手势,值会发生变化:四指向上滑动(切换应用程序)或五指捏合(返回主屏幕)。我尝试更改方法以仅响应“Touch Up Inside”事件,但无论如何,分段控件仍会通过多点触控手势更改值。

是否有某种方法可以继承 UISegmentedControl 以便 UIControlEventValueChanged 仅在单个段存在“内部修饰”事件时发生在控件上?

非常感谢!

【问题讨论】:

    标签: ios multi-touch uisegmentedcontrol


    【解决方案1】:

    问题是您的 UISegmentedControl 响应“UIControlEventValueChanged”。如果您只希望在内部触摸时调用您的方法,则让 UISegmentedControl 响应“UIControlEventTouchUpInside”。您不需要继承或覆盖任何东西。

    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button addTarget:self action:@selector(yourMethod:)
     forControlEvents:UIControlEventTouchUpInside];
    

    可在此处找到可用的控制事件:https://developer.apple.com/library/ios/documentation/uikit/reference/UIControl_Class/Reference/Reference.html

    【讨论】:

      猜你喜欢
      • 2011-08-22
      • 2020-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-05
      • 2020-12-12
      • 1970-01-01
      相关资源
      最近更新 更多