私は UIApplication::sendEvent オーバーライドにいます。最終的に UITouch オブジェクトを提供する UIEvent を取得します。UITouch のフェーズ == 3 (タッチ フェーズの終了またはタッチアップ) の場合、UITouch のビュー オブジェクトが UISegmentedControl であったかどうかを識別しようとします。はいの場合、selectedSegmentIndex を取得しようとします。この時点で、私は常に間違った値(またはselectedSegmentIndexの以前の値)を取得します。
この値は、そのアクション メソッドが実行された後にのみ変更されるということですか。または、selectedSegmentIndex の最新の値を取得するために何をする必要がありますか。
どんな助けでも感謝します。
- (void)sendEvent:(UIEvent *)event
{
[super sendEvent:event];
NSSet *touches = [event allTouches];
NSEnumerator *enumerator = [touches objectEnumerator];
id value;
while ((value = [enumerator nextObject])) {
UITouch *touch = value;
if (touch.phase==3) {
if([touch.view isKindOfClass:[UISegmentedControl class]])
{
UISegmentedControl *sc = (UISegmentedControl*)touch.view;
NSLog(@"%d",[sc selectedSegmentIndex]);
}
}
}
}