UIView框架没有调整包含UIScrollView的大小

时间:2014-06-04 11:13:17

标签: objective-c uiview uiscrollview orientation frame

我有一个包含UIView子视图的UIScrollView。这些都填满了整个窗口。我在IB中设置了这个。

在我的代码中我有这个:

- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
[self.fullViewScroller layoutIfNeeded];
self.fullViewScroller.frame = [self.view convertRect:self.fullViewScroller.frame fromView:nil];
CGRect newViewInScrollViewFrame =  CGRectMake(0, 0, self.fullViewScroller.frame.size.width, self.viewInScrollView.frame.size.height);
//self.viewInScrollView.frame = newViewInScrollViewFrame;
self.fullViewScroller.contentSize = newViewInScrollViewFrame.size;
NSLog(@"fullViewScroller.frame.size.height: %.2f; fullViewScroller.frame.size.width: %.2f", self.fullViewScroller.frame.size.height, self.fullViewScroller.frame.size.width);
NSLog(@"fullViewScroller.contentSize.height: %.2f; fullViewScroller.contentSize.width: %.2f", self.fullViewScroller.contentSize.height, self.fullViewScroller.contentSize.width);
NSLog(@"viewInScrollView.frame.size.height: %.2f; viewInScrollView.frame.size.width: %.2f", self.viewInScrollView.frame.size.height, self.viewInScrollView.frame.size.width);
}

我遇到的问题是,当我将方向更改为横向时,viewInScrollView后端不再与scrollView接触并保持其横向宽度。我尝试过更改框架大小(请参阅注释掉的代码)并添加约束,但我无法让它工作。

有没有人对我做错了什么有任何想法?

感谢您提供的任何帮助。

0 个答案:

没有答案