【问题标题】:UIView inside UIScrollView not resizing on 3,5 inches screen iOSUIScrollView 内的 UIView 未在 3,5 英寸屏幕 iOS 上调整大小
【发布时间】:2013-12-05 12:52:38
【问题描述】:

我需要你们的帮助/建议。

我正在使用 UIScrollView(水平)来显示一些数据。这个scrollView里面有一个自定义的UIView,是在Interface Builder中制作的。我没有使用自动布局(也许我应该......我试过了,但它看起来不像我想要的那样,或者我不明白它是如何工作的......)。

嗯,这是我的滚动视图驱动的代码:

- (void)loadList
{
    for (int i = 0; i < [DBManager getSharedInstance].getCountItems; i++) {

        Item *item = [[DBManager getSharedInstance] getCachedItemAtIndex:i];

        PanelPage *page = [[PanelPage alloc] initWithItem:item];

        CGRect frame;
        frame.origin.x = self.scrollView.frame.size.width * i;
        frame.origin.y = 0;
        frame.size = self.scrollView.frame.size;

        page.view.frame = frame;

        [self.scrollView addSubview:page.view];

    }

    self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * [DBManager getSharedInstance].getCountItems, self.scrollView.frame.size.height);

    self.pageControl.numberOfPages = [DBManager getSharedInstance].getCountItems;
}

效果很好。 scrollView 内 UIView 的大小:

高度:397px 宽度:285px

我有一个 UINavigationBar(64 像素高度)和一个 UITabBar(44 像素高度),在 iOS 7 上工作

对于 4 英寸的屏幕,它是完美的,但在 3.5 英寸上,我想调整我的 scrollView 内的视图大小,但我不知道如何进行。 A 尝试了很多东西,但没有好的结果:/

非常感谢您的帮助。

任何建议都值得赞赏;)

编辑:

好吧,我现在可以在屏幕大小改变时调整滚动视图的大小。见:https://stackoverflow.com/a/15401903/2061450

现在正在搜索调整滚动视图内视图的大小...

【问题讨论】:

    标签: ios iphone uiscrollview autolayout


    【解决方案1】:

    您应该在 viewDidAppear 中调用 loadList 函数,而不是之前(例如在 viewDidLoad 中)。

    【讨论】:

      猜你喜欢
      • 2013-05-05
      • 1970-01-01
      • 1970-01-01
      • 2014-05-29
      • 1970-01-01
      • 2020-11-16
      • 2019-12-17
      • 1970-01-01
      • 2015-01-25
      相关资源
      最近更新 更多