IOS8 UIscrollview 内部 uiview 问题

标签 ios iphone ios7 ios8

在 IOS8 中,我无法在 UIScrollView 下面添加 UIView。我使用的代码如下所示

UIScrollView *MainScroll=[[UIScrollView alloc]init];
MainScroll.backgroundColor=[UIColor redColor];
MainScroll.frame=CGRectMake(0, 0, 365,470);
[self.view addSubview:MainScroll];

UIView *HeaderView=[[UIView alloc]init];
HeaderView.backgroundColor=[UIColor orangeColor];
HeaderView.frame=CGRectMake(0,0,width,20);
[MainScroll addSubview:HeaderView];

在此代码中,HeaderView 未放置在 MainScroll 的起点。它放置在 UIScrollView 的一些空格之后。此问题仅在 IOS8 中发生。但在 IOS7 中,它工作正常,符合我的预期。

最佳答案

看到这个你的代码对我来说工作正常&我正在使用 Xcode 6 GM (iOS8 GM)。

代码:

UIScrollView *MainScroll=[[UIScrollView alloc]init];
MainScroll.backgroundColor=[UIColor redColor];
MainScroll.frame=CGRectMake(10, 100, 300, 200);
[self.view addSubview:MainScroll];

UIView *HeaderView=[[UIView alloc]init];
HeaderView.backgroundColor=[UIColor orangeColor];
HeaderView.frame=CGRectMake(0, 0, 300, 20);
[MainScroll addSubview:HeaderView]; 

iOS 8 结果:

enter image description here

iOS 7 结果:

enter image description here

关于IOS8 UIscrollview 内部 uiview 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25913088/

相关文章:

ios - 如何使用命令行在通过 USB 连接的手机上检查 iOS 应用程序的捆绑版本?

iphone - 如何检查我的字符串是否以大写字符开头

iphone - 如果我的实现或头文件导入了非 ARC 代码,这是否意味着该文件也是非 ARC 的?

iphone - NSDate 字符串未显示在 TableViewCell 中

ios - 有什么方法可以检查 iCloud Drive 是否打开?

ios - 如何从 iOS 中的 YTPlayer View 中删除标题和 channel 图标

ios - 如何仅在中国推出我的 iOS iPhone 应用程序?

iphone - 如何在 ios 中创建对象的新实例?

ios - 无法为 IOS7 创建应用程序图标

ios - 似乎无法让 ApplyForce() 以一种有意义的方式工作