【发布时间】:2016-09-07 07:10:22
【问题描述】:
这就是我在viewDidLoad 中添加UIScrollView 的方式
UIScrollView* scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
scrollView.backgroundColor = [UIColor redColor];
scrollView.scrollEnabled = YES;
scrollView.pagingEnabled = YES;
scrollView.showsVerticalScrollIndicator = YES;
scrollView.showsHorizontalScrollIndicator = YES;
scrollView.contentSize = CGSizeMake(self.view.bounds.size.width , self.view.bounds.size.height * 2);
[self.view addSubview:scrollView];
scrollView.delegate = self;
第一次加载scrollView时,它的坐标是:{(0,0), (widthOfiPhone, 0), (0, heightOfiPhone), (widthOfiPhone, heightOfiPhone)}
每当滚动完成时,我想在滚动视图中获取视口的坐标。这该怎么做?谢谢
图片来源:https://oleb.net/blog/2014/04/understanding-uiscrollview/
【问题讨论】:
-
viewport是什么意思? -
在任何给定时间点在屏幕上可见的滚动视图的内容。比如说,如果我的 contentsize 是 320*1500,在 iphone 5s 上,当第一次加载滚动视图时,视口的坐标是 {(0,0), (320, 0), (0, 568), (320, 568)}
-
@VamshiKrishna 您的问题不清楚。添加更多详细信息,以便有人可以为您提供好的解决方案
标签: ios objective-c uiscrollview uiscrollviewdelegate