Если вы используете метод IBAction, вы можете использовать (id)sender
в качестве его параметра. (то есть вызывающая кнопка) Затем вы можете установить прямоугольник прикрепления поповера к рамке кнопки. Стрелка приложит все усилия, чтобы прикрепить ее вдоль стороны этого кадра в соответствующем месте См. Справочник по классам UIPopoverController .
-(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];
}
При необходимости вы также можете жестко закодировать этот CGRect вручную. Уменьшение ширины / высоты прямоугольника позволит вам более жестко контролировать положение стрелки.