2

在我的 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];     
}

你有什么想法或建议来解决这个问题吗?谢谢!

4

1 回答 1

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。

于 2011-05-23T10:40:08.517 回答