Я программно создал UITableView и добавил UISwitch в это представление сотового аксессуара.
Это мой код для UISwitch в представлении аксессуаров ячейки в cellForRowAtIndexPath
.
UISwitch *accessorySwitch = [[UISwitch alloc]initWithFrame:CGRectZero];
[accessorySwitch setOn:NO animated:YES];
[accessorySwitch addTarget:self action:@selector(changeSwitch:) forControlEvents:UIControlEventValueChanged];
cell.accessoryView = accessorySwitch;
Это метод, который вызывается после нажатия кнопки.
- (void)changeSwitch:(UISwitch *)sender{
UITableViewCell *cell = (UITableViewCell *)[sender superview];
NSIndexPath *indexPath = [self.filterTableView indexPathForCell:cell];
NSLog(@"%ld",(long)indexPath);
……………. My other code…….
}
Я могу напечатать значение пути индекса в iOS 6 Но в iOS 7 он печатает нуль,
Мне что-то не хватает в iOS 7 или есть какой-то другой подход, чтобы получить indexPath в iOS 7
Спасибо, Арун.