开发者

Popover in scroll view

开发者 https://www.devze.com 2023-03-06 11:09 出处:网络
In my iPad App, I use a popover with an arrow on a button in a scroll view. It works fine but when I scroll the view, then tap on the button, the popover with the arrow doesn\'t follow the buttom, it

In my iPad App, I use a popover with an arrow on a button in a scroll view. It works fine but when I scroll the view, then tap on the button, the popover with the arrow doesn't follow the buttom, it opens at its original position.

I use this code:

(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:popove开发者_StackOverflow社区rButtonForHome.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];     
}

Do you have any idea or suggestion to fix this problem? Thanks!


Hey, try something like this:

- (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];
}

I just needed exactely the same ... the code works for my uibutton in a uiscrollview.

0

精彩评论

暂无评论...
验证码 换一张
取 消