iPhone SDK:UIScrollView不滚动

iPhone SDK:UIScrollView不滚动,iphone,objective-c,uiscrollview,uiimageview,Iphone,Objective C,Uiscrollview,Uiimageview,我只是无法让我的滚动视图真正滚动。。所有内容都显示良好,只是无法滚动。。。。。这是我的密码: - (void)viewDidLoad { [super viewDidLoad]; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 600)]; scrollView.contentSize = CGSizeMake(320, 600); scro

我只是无法让我的滚动视图真正滚动。。所有内容都显示良好,只是无法滚动。。。。。这是我的密码:

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

如何解决此问题?

如果要滚动任何内容,则
contentSize
必须大于scrollview的框架。:)

在本例中,它们都是
(320600)
,因此将scrollView的init更改为

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];

您的scrollview框架应小于contentSize,因此只有您可以使scrollview可滚动。

好消息。加一!