ios - UIScrollView 不起作用(无法滚动)

标签 ios objective-c cocoa-touch uiscrollview

我将 UIScrollView 添加到我正在制作的可重用 View 中,然后将该可重用 View 添加到 UIViewController 中。

在我的可重用 View 中,我将 UIView 添加到 UIScrollView 中:

 int yLocation = 20;
    for (int i= 0 ; i < 5; i++) {
        UIView *tempView = [[offerCell alloc]initWithDelegate:self];
        tempView.frame = CGRectMake(5, yLocation, 290.0F, 70.0F);

        yLocation += 90;

        [self.scrollView addSubview:tempView];
        UILabel *tempLabel = [tempView viewWithTag:1000];
        tempLabel.text = [NSString stringWithFormat:@"Label Number %d" , i];
        [tempLabel sizeThatFits:CGSizeMake(1000, 1000)];
    } 
    self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width, yLocation);

然后我将 UIView 添加到我的 UIViewController

UIView *tempView = [[BuyTokensView alloc] initWithDelegate:self andViewController:self];
[self.view addSubview:tempView];
CGPoint point = CGPointMake(10, 0);
tempView.center = point;

View 显示正确,但我无法滚动 UIScrollView。我的 UIScrollView 高度小于我在 ContentSize 中指定的高度,为什么我无法滚动?

这是 UIViewController 的图片: image 1

最佳答案

您可以尝试禁用自动布局或使用本技术说明中的策略:

https://developer.apple.com/library/ios/technotes/tn2154/_index.html#//apple_ref/doc/uid/DTS40013309

关于ios - UIScrollView 不起作用(无法滚动),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20165704/

相关文章:

android - 使用不透明蒙版时图像的自动变换失败

ios - 将数据从 locationmanager(..didrangbeacons) 传递到 collectionview(...cellforitemat)

ios - 代码=-1011 "Request failed: unauthorized (401)"AFNetworking

iphone - 为什么更改 UITextField 在一种情况下会导致无限循环,而在另一种情况下不会?

iphone - 如何在调试器中查找属性值?

ios - iOS 应用程序中的生产崩溃日志

ios - 带 IOS 的 PJSip,麦克风音量非常低

ios - 自定义 UITableViewCell 高度会产生不正确的动画

objective-c - 全局应用程序监控 macos/cocoa/objective-c

objective-c - Xcode/git 不适用于子文件夹