无法在UIViewController中看到添加的UIScrollView

时间:2015-04-04 18:37:36

标签: ios objective-c iphone uiviewcontroller uiscrollview

我在主UIScrollView添加了UIViewController,但由于某种原因,我看不到任何内容。我画了灰色的滚动视图以查看实际尺寸,但我得到的只是一个白色的屏幕。

这是我非常简单的代码:

-(void) viewDidLoad{
[super viewDidLoad];
UIScrollView *scroll;
[scroll setBackgroundColor:[UIColor grayColor]];


CGRect screenRect = [[UIScreen mainScreen] bounds];
_orientation = [UIDevice currentDevice].orientation;

if (UIDeviceOrientationIsPortrait(_orientation)){
    scroll.showsHorizontalScrollIndicator = YES;
}else{
    scroll.showsVerticalScrollIndicator = YES;
}

scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(screenRect.origin.x,
                                                        screenRect.origin.y,
                                                        screenRect.size.width,
                                                        screenRect.size.height)];
[self.view addSubview:scroll];
}

视图大小可能会发生变化,我正在改变iOS设备的大小。

0 个答案:

没有答案