title: How to call PopOver Controller from UITableViewCell.accessoryView?
body: <p>First I would like to say that I'm really new to ipad/ipod/iphone development, and to objective-c too.</p>
  
  <p>With that being said, I'm trying to develop a small application targeting the iPad, using Xcode and IB, basically, I have a table, for each UITableViewCell in the table, I added to the accessoryView a button that contains an image.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>UIImage *img = [UIImage imageNamed:@"myimage.png"];
  UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  CGRect frame = CGRectMake(0.0, 0.0, img.size.width, img.size.height);
  button.frame = frame;   // match the button's size with the image size
  
  [button setBackgroundImage:img forState:UIControlStateNormal];
  
  // set the button's target to this table view controller so we can interpret touch events and map that to a NSIndexSet
  [button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside];
  button.backgroundColor = [UIColor clearColor];
  cell.accessoryView = button;
  </code></pre>
  
  <p>So far, so good, now the problem is that I want a PopOver control to appear when a user taps the button on the accessoryView of a cell.</p>
  
  <p>I tried this on the "accessoryButtonTappedForRowWithIndexPath" of the tableView:</p>
  
  <pre><code>UITableViewCell *cell = [myTable cellForRowAtIndexPath:indexPath];
  UIButton *button = (UIButton *)cell.accessoryView;
  
  //customViewController is the controller of the view that I want to be displayed by the PopOver controller
  customViewController = [[CustomViewController alloc]init];
  
  popOverController = [[UIPopoverController alloc]
  initWithContentViewController: customViewController];
  
  popOverController.popoverContentSize = CGSizeMake(147, 122);
  
  CGRect rect = button.frame;
  
  [popOverController presentPopoverFromRect:rect inView:cell.accessoryView
  permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
  </code></pre>
  
  <p>The problem with this code is that it shows the Popover at the top of the application View, while debugging I saw the values of "rect" and they are:</p>
  
  <pre><code>x = 267
  y = 13
  </code></pre>
  
  <p>so I think it is pretty obvious why the PopOver is being displayed so up on the view, so my question is, how can I get the correct values for the PopOver to appear just below the button on the accessoryView of the cell?</p>
  
  <p>Also, as you can see, I'm telling it to use the "cell.accessoryView" for the "inView:" attribute, is that okay?</p>