【问题标题】:How to hook up UIPageControl so it scrolls up with other controls?如何连接 UIPageControl 使其与其他控件一起向上滚动?
【发布时间】:2013-03-12 21:15:45
【问题描述】:

我在视图控制器的主 UIView 中放置了一个 UIScrollView。

然后我在视图底部添加了一些控件,并在顶部附近添加了一个 UIPageControl。

当我滚动视图时,底部控件滚动正常,但 UIPageControl 保持在原位,因此它最终挡住了底部的按钮和标签。

如何使 UIPageControl 及其视图随其余部分向上或向下滚动?

这是它的样子

【问题讨论】:

  • 您找到解决问题的方法了吗?我遇到了完全相同的问题。
  • @canpoyrazoğlu 老实说,我只是将所有东西移回原处以使其适合。从场景检查器中可以看到,一切都在 UIScrollView 内。
  • 我的页面控件也在滚动视图中,但它没有滚动。即使所有约束都设置正确,它也只是停留在原处。看到这个:stackoverflow.com/questions/21259275/…

标签: uiscrollview uipagecontrol


【解决方案1】:

我让它工作了:

1) 将所有视图/控件放入 containerView 中并将其声明为属性。

2) 添加此代码:

-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    self.scrollView.contentSize = self.containerView.bounds.size;
}

- (void)viewDidLoad{
    [super viewDidLoad];

    //added with containerview from g8productions
    self.containerView =  [[UIView alloc] initWithFrame:CGRectMake(36, 59, 900, 1200)];
    self.scrollView.translatesAutoresizingMaskIntoConstraints = NO;
    [self.scrollView addSubview:self.containerView];
    [self.scrollView setContentSize:self.containerView.bounds.size];
}

现在它滚动了! :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-15
    • 2022-12-06
    相关资源
    最近更新 更多