【发布时间】:2013-06-06 08:29:41
【问题描述】:
在我的应用程序的 iPad 版本中,我有一个 UIView,TPKeyboardAvoidingScrollView 的子视图,由 xib 创建,其框架为 (0.0, 1024, 437)。当您在输出框架中运行应用程序时,相应地变为(0.0, 1024, 800),其高度几乎是它应该具有的两倍。这是什么意思?我该如何解决?
代码:
//self.scrollView is a TPKeyboardAvoidingScrollView
CGFloat width = self.scrollView.frame.size.width;//is correct
CGFloat progY = 0;
self.view1.frame = CGRectMake(0, progY, width,
self.view1.frame.size.height);
[self.scrollView addSubview:self.view1];
progY+= self.view1.frame.size.height;
//is correct, the height is equal to that of the xib
self.view2.frame = CGRectMake(0, progY, width, self.view2.frame.size.height);
NSLog(@"the frame of view2 is %@", NSStringFromCGRect(self.view2.frame));
//the frame of view2 is {{0, 215}, {1024, 800}}
//the height would be 437 as in xib
[self.scrollView addSubview:self.view2];
progY+= self.view2.frame.size.height;//is wrong
//....
【问题讨论】:
-
你如何/在哪里初始化
UIView? -
如果您已经在 xib 中设置了,那么需要以编程方式更改框架。如果视图已经在 xib 中实现,我不希望更改框架。
-
UIView 已经在 xib 中实现了,我想保持相同的高度,而不是改变