If you are using an IBAction method, you can use (id)sender
as its parameter. (i.e. the calling button) Then you can set the popover's attachment rectangle to the frame of the button. The arrow will do its best to attach along the side of this frame in an appropriate spot. See UIPopoverController Class Reference.
-(IBAction)sortButtonPressed:(id)sender {
// Set up your popover class, this varies per your implementation
MyPopoverClass *iPop = [[MyPopoverClass alloc] initWithNibName:@"MyPopover" bundle:nil];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:iPop];
// Grab the button info from the input parameter
UIButton *button = (UIButton *)sender;
CGRect buttonRectangle = button.frame;
// Set the arrow direction
UIPopoverDirection dir = UIPopoverArrowDirectionAny; // Or Up, Down, etc.
// Put it all together
[popover presentPopoverFromRect:buttonRectangle inView:mySubView permittedArrowDirections:dir animated:YES];
[popover release]
[iPop release];
}
You can also hardcode that CGRect by hand if necessary. Shrinking the width/height of the rectangle will allow you to more tightly control the arrow's position.