在我的iPad应用程序中,我在滚动视图中使用带有箭头的弹出按钮。它工作正常,但是当我滚动视图,然后点击按钮,带箭头的弹出窗口不跟随按钮,它在原始位置打开。
我使用此代码:
(void)showHomePopupAction:(id)sender {
self.popHome = [[[PopHome alloc] initWithNibName:@"PopHome" bundle:[NSBundle mainBundle]] autorelease];
popHome.contentSizeForViewInPopover = CGSizeMake(popHome.view.frame.size.width, popHome.view.frame.size.height);
self.popoverController = [[[UIPopoverController alloc] initWithContentViewController:popHome] autorelease];
[self.popoverController presentPopoverFromRect:popoverButtonForHome.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
您有什么想法或建议来解决这个问题吗? 谢谢!
答案 0 :(得分:5)
- (void)showHomePopupAction:(id)sender {
self.popHome = [[[PopHome alloc] initWithNibName:@"PopHome" bundle:[NSBundle mainBundle]] autorelease];
popHome.contentSizeForViewInPopover = CGSizeMake(popHome.view.frame.size.width, popHome.view.frame.size.height);
self.popoverController = [[[UIPopoverController alloc] initWithContentViewController:popHome] autorelease];
CGRect frame = popoverButtonForHome.frame;
frame.origin.y -= self.scrollView.bounds.origin.y; // you can postion the popover with + and - values
[self.popoverController presentPopoverFromRect:frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
我只需要完全一样......代码适用于uiscrollview中的uibutton。