iOS IndexPath는 nil (사용자 정의 액세서리 이미지)입니다.
-
13-11-2019 - |
문제
Apple에서 "액세서리"에 대한 샘플 코드를 사용하여 내 테이블에 사용자 정의 액세서리 이미지가 있습니다.이 테이블은 이미지를 제대로 렌더링하고 모든 것을 accessorybuttontappedForrowWithIndexpath 메서드로 가져 가려고 할 수있는 이미지를 클릭하면 IndexPath가 어떤 이유로 인한 이유가 있기 때문에 아무 일도 일어나지 않습니다.IndexPath를 확인하는이 메소드를 참조하십시오.
.- (void)accessoryButtonTapped:(id)sender event:(id)event
{
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition];
if (indexPath != nil)
{
[self tableView: self.tableView accessoryButtonTappedForRowWithIndexPath: indexPath];
}
}
해결책
tableView:accessoryButtonTappedForRowWithIndexPath:
에서 UITableViewDelegate
를 사용할 수없는 이유는 무엇입니까?