Last active
August 29, 2015 13:56
-
-
Save TomoyaOnishi/9152054 to your computer and use it in GitHub Desktop.
UISwitchのバグ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// UISwitchのバグ | |
// スワイプでON・OFFしようとすると | |
// セットしたセレクタが連続で呼び出される。 | |
UISwitch *hogeSwitch = [[UISwitch alloc] init]; | |
hogeSwitch.center = self.view.center; | |
[hogeSwitch addTarget:self action:@selector(hogeSwitchDidChangeValue:) forControlEvents:UIControlEventValueChanged]; | |
[self.view addSubview:hogeSwitch]; | |
} | |
- (void)hogeSwitchDidChangeValue:(UISwitch *)hogeSwitch | |
{ | |
// バグ対応として以前の値と同じ時はreturn | |
if (self.previousSwitchValue == hogeSwitch.isOn) { | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
UISwitchに対してUIControlEventTouchUpInsideを当てるとイベントが取れないことがあるので、使えない。