在我的应用程序的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
//....
答案 0 :(得分:3)
XIB中的基本视图可能具有错误的自动调整属性等。
在尺寸检查器中查看基本视图的自动调整设置 - 它不应该连接到屏幕的下端,也不能动态改变高度,那么你没事。