sickanimations/ActionSheetPicker — Issue #28: UIPopoverController and UITableViewCell
Author: nberthel
Created: 2011-12-19 19:36:47+00:00
State: open

In order to place UIPopoverController on Table Cell, I've done this small quick fix, maybe it can help someone else. It works in my case, not sure if it will work in any case ;).

in :

```objective-c
- (void)presentPopover:(UIPopoverController *)popover
```

just put

```objective-c
if (self.barButtonItem) {
[popover presentPopoverFromBarButtonItem:_barButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
return;
}
else if ((self.containerView) && NO == CGRectIsEmpty(self.presentFromRect)) {
NSParameterAssert(popover != NULL);
if ([self.containerView isKindOfClass:[UITableViewCell class]]) {
UITableViewCell *cell = (UITableViewCell*) self.containerView;
UIButton *button = (UIButton *)cell.accessoryView;
_presentFromRect = cell.bounds;
_presentFromRect.origin.x = button.bounds.size.width / 2;
[popover presentPopoverFromRect:_presentFromRect inView:_containerView permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
return;
} else {
[popover presentPopoverFromRect:_presentFromRect inView:_containerView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
return;
}
}
```

I'm new to Objective-c, so this peace of code can probably be enhanced.

Nicolas