【问题标题】:UISegmentedControl : Could not call the method in ios 5.0UISegmentedControl:无法调用 ios 5.0 中的方法
【发布时间】:2012-03-07 11:01:35
【问题描述】:

我正在修改一个 iPhone 应用,

当我改变分段按钮的值时,

它应该调用方法,

- (void) setSelectedSegmentIndex:(NSInteger)index

我在我的自定义类中覆盖了它。

没有与段关联的 IBAction。

在 ios 4.3 中它被调用。 但是,在 ios 5.0 中它不会被调用。

这是它的 ResultUnitSwitch.h 文件

@interface ResultUnitSwitch : UISegmentedControl {

    id <ResultUnitDelegate> delegate;

    MCUnit *activeUnit;

    NSArray *units;             
}


There is a method call stack for ios 4.3

那么,为什么它在 ios 4.3 而不是同一项目的 ios 5.0 中被调用,是否有任何改变是 UISegmentedControl

【问题讨论】:

    标签: iphone objective-c xcode ios5 ios4


    【解决方案1】:

    setSelectedSegmentIndex 是一个为外部使用而设计的属性设置器。您的应用依赖于未记录的内部框架使用,因此无法保证这将永远有效。

    您可以覆盖一个 init-Method(initWithCoder:如果您使用 XIB)来添加您的子类的方法作为事件目标:

    [self addTarget:self action:@selector(action:) forControlEvents:UIControlEventValueChanged];
    

    【讨论】:

      猜你喜欢
      • 2013-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-10
      • 1970-01-01
      • 2012-01-25
      • 2013-04-15
      • 2011-11-19
      相关资源
      最近更新 更多