私は、いくつかのセルに UISwitch を持つ UITableView を持っています。
イベントをキャプチャしたいのですが、indexPath を追加しようとするとクラッシュします。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//Create cell with all data
UISwitch *switchview = [[UISwitch alloc] initWithFrame:CGRectZero];
cell.accessoryView = switchview;
[switchview addTarget:self action:@selector(updateSwitchAtIndexPath) forControlEvents:UIControlEventTouchUpInside];
}
- (void)updateSwitchAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
UISwitch *switchView = (UISwitch *)cell.accessoryView;
if ([switchView isOn]) {
NSLog(@"ON");
} else {
NSLog(@"OFF");
}
}
indexPath パラメータを追加していないためだと思いますが、設定方法がわかりません。
-[ParkingData updateSwitchAtIndexPath]: unrecognized selector sent to instance 0x7b88eb0
ありがとう!