1
그래서 기술적으로는 UISwitch 아니라 단지 UISwitch (https://github.com/domesticcatsoftware/DCRoundSwitch)indexPath는 tableView 셀의 Custom UISwitch에 대해 null을 반환합니까?
나는 테이블의 모든 행에이 DCRoundSwitch을 사용하고처럼 동작 사용자 정의 클래스와의 UIView 아니다. DCRoundSwitch가있는 행의 indexPath를 가져오고 싶지만 null을 반환합니다. 여기
가 DCRoundSwitch 구성하는 방법입니다 (값이 변경 사용) : 당신이 볼 수 있듯이
-(void)togglePublic:(UIControl *)button withEvent:(UIEvent *)event {
DCRoundSwitch *switch1 = (DCRoundSwitch *)button;
UITableViewCell *cell = (UITableViewCell *)switch1.superview;
NSIndexPath *indexPath = [self.tableview indexPathForCell:cell];
NSLog(@"PUBLICSWITCH PRESSED %@", indexPath);
//NSIndexPath * indexPath = [self.tableview indexPathForRowAtPoint:[[[event touchesForView: button] anyObject] locationInView: self.tableview]];
if (indexPath == nil){
return;
}
AHBContact *contact = [self.contacts[indexPath.section] allValues][0][indexPath.row];
NSLog(@"Public switch toggled for: %@", contact);
}
가의 indexPath가 마치 nil을 반환
여기 내 togglePublic 방법입니다 "Public switch toggled :"로그 메시지에 도달하기 전에 항상 메소드가 리턴됩니다.
좋은 아이디어. 돌아 오는 것을 확인하는 좋은/빠른 방법은 무엇입니까? – Rohan
nvm. 그것을 얻었다 - 당신이 옳았다! 기대했던 것보다 한 아이가 낮았다. – Rohan