Appleの例のように、カスタムの開示ボタンを使用しようとしています。私は次のことをしています
- (void) customButtonTapped:(UIButton *)sender event: (id) event{
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition];
NSLog(@"index path %@", indexPath);
if (indexPath != nil)
{
}
}
問題は、インデックスパスが常にnilであるということです。毎回必ず。他の誰かがこれに出くわしましたか?
編集 これは私がボタンを追加する方法です
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
UIImage *image = [UIImage imageNamed:@"Gear"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
button.frame = frame;
[button setBackgroundImage:image forState:UIControlStateNormal];
button.backgroundColor = [UIColor clearColor];
[button addTarget:self action:@selector(customButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = button;