回答我的問題,以幫助一些之一,
// Presenting from BarButton will not dismiss popover when we click on other bar button.
// [self.popoverController presentPopoverFromBarButtonItem:self.barButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
NSMutableArray* buttons = [[NSMutableArray alloc] init];
for (UIView *subview in self.navigationController.navigationBar.subviews) {
if ([subview isKindOfClass:[UIControl class]]) {
[buttons addObject:subview];
}
}
UIView *view = [buttons objectAtIndex:1]; // The '1' is the index to your bar item in the array of .items
CGRect barButtonFrame = [self.navigationController.navigationBar convertRect:view.frame toView:self.navigationController.view];
[self.popoverController presentPopoverFromRect:barButtonFrame inView:self.navigationController.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
我上面所做的是找到欄按鈕和顯示酥料餅「presentPopoverFromRect」的框架。
但是我在我的情況下,有5 barbutton運用不同的酥料餅的實例。現在我解決了這個問題。但爲什麼這兩種表示方法的行爲不同。 – 2013-04-05 06:55:52