我下面的UIScrollView没有水平滚动,请在这里帮助我。

FirstView = [[UIView alloc] initWithFrame:CGRectMake(60, 0, 100, 150)];
    [FirstView setBackgroundColor:[UIColor clearColor]];

    SecondView = [[UIView alloc] initWithFrame:CGRectMake(320+60, 0, 100, 150)];
    [SecondView setBackgroundColor:[UIColor clearColor]];

    HolderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 1000, 150)];

    scrHorizontalScroll = [[UIScrollView alloc]initWithFrame:HolderView.frame];
        [scrHorizontalScroll setBackgroundColor:[UIColor redColor]];
    [scrHorizontalScroll setContentSize:CGSizeMake(999, 150)];
    [scrHorizontalScroll setScrollEnabled:YES];
    [HolderView addSubview:scrHorizontalScroll];
[scrHorizontalScroll addSubView:FirstView]; [scrHorizontalScroll addSubView:SecondView]; [HolderView addSubView: scrHorizontalScroll];

HolderView不会水平滚动,但是会发生这种情况,请帮忙

注意:我有一个mainView,它根据帧坐标在其顶部添加了HolderView。
[mainView addSubView:label].... [mainView addSubView:HolderView];

这是完整的结构

最佳答案

滚动 View 仅在其内容大小大于其框架时滚动。

10-07 19:13