次のコードで UISwitch を作成しました。
CGRect switchFrame = CGRectMake(200, 10, 94, 27);
UISwitch *yesNo = [[[UISwitch alloc] initWithFrame:switchFrame] autorelease];
[yesNo addTarget:self action:@selector(handleSwitch:) forControlEvents:UIControlEventValueChanged];
ただし、スイッチの状態に関係なく、視覚的に であっても、on
プロパティは常に を返します。YES
NO
イベント ハンドラは次のようになります。
-(IBAction) handleSwitch: (UISwitch *) sender{
self.displayCompleted = sender.on;
}
displayCompleted プロパティを設定します。
-(void) setDisplayCompleted:(BOOL)newValue{
displayCompleted = newValue;
[[self tableView] reloadData];
}
何が原因でしょうか?