This is my view layout in storybaord:
这是我在storybaord的视图布局:
My Scroll view frame is set to be 320x568
, and in my view controller I have set
我的滚动视图框架设置为320x568,在我的视图控制器中设置。
self.scrollView.scrollEnabled = YES;
[self.scrollView setContentSize:CGSizeMake(320,1000)];//obviously content is larger than frame
However, the scroll still doesn't work. So I enabled vertical bounce, and found that every time when I drag down it just bounces back to original position. Can anyone help me fix this issue?
然而,卷轴仍然不能工作。所以我启用了垂直弹跳,并且发现每次当我向下拖动时它会反弹回原来的位置。有人能帮我解决这个问题吗?
4 个解决方案
#1
0
First turn off AutoLayout - click on scrollview and uncheck Use AutoLayout
首先关闭自动播放-单击scrollview并取消使用AutoLayout。
In your .h file add the UIScrollViewDelegate for example:
在您的.h文件中添加UIScrollViewDelegate:
@interface myViewController : UIViewController <UIScrollViewDelegate>
@interface myViewController: UIViewController
In your .m file in viewDidLoad set
在viewDidLoad集中的.m文件中。
self.myScrollView.delegate = self;
self.myscrollView.scrollEnabled = YES;
self.myscrollView.contentSize=CGSizeMake(320.0, 1094.0);
keep Bounces ON and set scrollview frame 320 X 960
保持弹跳和设置scrollview框架320 X 960。
#2
0
In your .h file add the UIScrollViewDelegate
for example:
在您的.h文件中添加UIScrollViewDelegate:
@interface myViewController : UIViewController <UIScrollViewDelegate>
In your .m file in viewDidLoad set
在viewDidLoad集中的.m文件中。
self.myScrollView.delegate = self;
#3
0
If you have one subview in your scrollview, as you do, the scrollview will scroll to the dimensions of that view. See the answer here for details.
如果您的scrollview中有一个子视图,那么scrollview将滚动到该视图的维度。详见这里的答案。
#4
0
view.userInteractionEnabled = YES
视图。userInteractionEnabled = YES
#1
0
First turn off AutoLayout - click on scrollview and uncheck Use AutoLayout
首先关闭自动播放-单击scrollview并取消使用AutoLayout。
In your .h file add the UIScrollViewDelegate for example:
在您的.h文件中添加UIScrollViewDelegate:
@interface myViewController : UIViewController <UIScrollViewDelegate>
@interface myViewController: UIViewController
In your .m file in viewDidLoad set
在viewDidLoad集中的.m文件中。
self.myScrollView.delegate = self;
self.myscrollView.scrollEnabled = YES;
self.myscrollView.contentSize=CGSizeMake(320.0, 1094.0);
keep Bounces ON and set scrollview frame 320 X 960
保持弹跳和设置scrollview框架320 X 960。
#2
0
In your .h file add the UIScrollViewDelegate
for example:
在您的.h文件中添加UIScrollViewDelegate:
@interface myViewController : UIViewController <UIScrollViewDelegate>
In your .m file in viewDidLoad set
在viewDidLoad集中的.m文件中。
self.myScrollView.delegate = self;
#3
0
If you have one subview in your scrollview, as you do, the scrollview will scroll to the dimensions of that view. See the answer here for details.
如果您的scrollview中有一个子视图,那么scrollview将滚动到该视图的维度。详见这里的答案。
#4
0
view.userInteractionEnabled = YES
视图。userInteractionEnabled = YES