我想在图像视图中显示图像(宽度:320像素,高度:1250像素).
当我编译应用程序时,我根本没有滚动.视图保持不变.
我做了什么:
UIScrollViewvia Interface Builder.UIImageView在我的视图中添加了一个via Interface Builder.UIImageView以下内容UIScrollView.UIScrollViewwith 的大小ViewDidLoad.我该怎么做呢?
码:
- (void)viewDidLoad
{
[super viewDidLoad];
scrollView.contentSize = CGSizeMake(320, 1250);
}
Run Code Online (Sandbox Code Playgroud)
截图:
ImageView:

ScrollView:


我只是无法让我的滚动视图实际滚动..一切都显示正常,除了它只是不会滚动.....这是我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 600)];
scrollView.contentSize = CGSizeMake(320, 600);
scrollView.scrollEnabled = YES;
scrollView.clipsToBounds = YES;
[self.view addSubview:scrollView];
planView = [[WorkoutPlanView alloc] initWithImage:[UIImage imageNamed:@"WorkoutTable.png"]];
planView2 = [[WorkoutPlanView alloc] initWithImage:[UIImage imageNamed:@"WorkoutTable.png"]];
planView2.frame = CGRectMake(0, 164, 320, 165);
planView3 = [[WorkoutPlanView alloc] initWithImage:[UIImage imageNamed:@"WorkoutTable.png"]];
planView3.frame = CGRectMake(0, 328, 320, 165);
planView4 = [[WorkoutPlanView alloc] initWithImage:[UIImage imageNamed:@"WorkoutTable.png"]];
planView4.frame = CGRectMake(0, 505, 320, 165);
[scrollView addSubview:planView];
[scrollView addSubview:planView2];
[scrollView addSubview:planView3];
[scrollView addSubview:planView4];
}
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
我在我的应用程序中使用scrollViewDidScroll委托.
但是,很多时候,即使我开始滚动,这个委托也会被调用,这会产生很多问题.我听说即使设置了特定滚动视图的contentSize,那么此时该委托scrollViewDidScroll即将调用.
调用此委托的不同方案有哪些.控制它的步骤是什么?
我可以设置任何参数来处理这个吗?