I am creating an application for the iPad, and I want to show an UIPopoverController
with an arrow pointing to the detail disclosure button for the row it belongs t
To do what you want, you need an accessoryView and setting the accessoryType does not create one. However, it will work if you create a button and set it as the cell.accessoryView.
Create and set the accessoryView when the cell is created:
...
UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[disclosureButton addTarget:self action:@selector(discloseDetails:) forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = disclosureButton;
...
Replace tableView:accessoryButtonTappedForRowWithIndexPath: with discloseDetails:. This looks much like what you have before so I've only put the changes below:
- (void) discloseDetails:(UIButton *)sender {
...
UITableViewCell *cell = (UITableViewCell *) sender.superview;
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell]; // if needed
[addFeedPopup presentPopoverFromRect:cell.accessoryView.bounds inView:cell.accessoryView permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
...
}
If you don't need the cell, it can be made even simpler:
- (void) discloseDetails:(UIButton *)sender {
...
[addFeedPopup presentPopoverFromRect:sender.bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
...
}
Here's what it looks like