So, I spent some time searching for an answer, but so far have not found anything.
I am trying to present a popover from a button on a UIInputAccessoryView. The UIBarButtonItem with which I want to display a popover has a custom look, so I can use an image. I create a button as follows:
buttonImage=[UIImage imageNamed:@"tags.png"]; aButton=[UIButton buttonWithType:UIButtonTypeCustom]; [aButton setImage:buttonImage forState:UIControlStateNormal]; aButton.frame=CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height); UIBarButtonItem* compButton2=[[UIBarButtonItem alloc]initWithCustomView:aButton]; [aButton addTarget:self action:@selector(tagIt:) forControlEvents:UIControlEventTouchUpInside];
When the time comes to display a popover, I do it like this:
CGRect tRect=[((UIButton*)sender) convertRect:((UIButton*)sender).frame toView:self.notePlainText]; NSLog(@"TagIt tRect: %f %f %f %f", tRect.origin.x, tRect.origin.y, tRect.size.width, tRect.size.height); [self.popoverController presentPopoverFromRect:tRect inView:self.notePlainText permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
But I get the following:

Popsor looks great, but it appears above the second button when it should appear above the first.
So, I found this question: UIBarButtonItem with a custom image and without borders , and I thought: “Ah, it might work better if I present a popover from barbuttonitem instead of doing it this way. Subclass UIBarButtonItem classes in order to to have a button with an image, not text, and represents the barbuttonitem correctly when the action is called.This allowed me to use ... presentPopoverFromBarButtonItem ...
So, I tried the code in the second answer in the above question and got a result that was better. Popover points to the button as I wanted, but if the orientation of the device is not a portrait with the button below, then popover displays the wrong orientation:

Finally, I will point out that I have other elements of the bar panel elsewhere in the program that are not in UIInputAccessoryViews that appear correctly and without problems. It looks like this comes from the look of input accessories.
It's simple: Hiding and showing the keyboard seems to make this work a little better. Considering the frame data (CGRect) for a button, it does not change between rotations unless it is hidden and returned. This is mistake?
So my question is this: what is the preferred, best way to present a popover from a button element on a panel embedded in an ui accessory?
Many thanks.