代码之家  ›  专栏  ›  技术社区  ›  Kyle

将uiscrollview内容视图位置映射到其框架?

  •  2
  • Kyle  · 技术社区  · 15 年前

    我有一个UIScrollView,其中内容大小大于框架。我正在显示UIPopoverController,并希望使用UIImageView的框架来调用设置popover的放置位置:

    [popoverController presentPopoverFromRect: imageView.frame inView: self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    

    有没有办法把这个位置映射到正确的位置?

    1 回复  |  直到 15 年前
        1
  •  1
  •   Raphaël Mor    14 年前

    - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view

    比如:

    CGRect convertedFrame = [scrollView convertRect:imageView.frame toView:self.view];
    [popoverController presentPopoverFromRect:convertedFrame inView: self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    
    推荐文章