iOS 8 +,Objective-C
我正在UISplitViewController
工作,并且我在detailViewController上实现了textFields。我有底部视图以获得额外的两个按钮,底部视图的高度为60px,宽度取决于设备的旋转。
所以,我想知道当splitViewController的displayMode为UISplitViewControllerDisplayModeAllVisible
时如何获取detailViewController的视图大小。
任何帮助将不胜感激。
修改
我正在尝试使用viewController中的以下代码,
#define TABBAR_HEIGHT 50.0f
#define NAVIGATION_HEIGHT 64.0f
#pragma mark- ScreenRotation
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
[self calculateFrameForFooterView];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return YES;
}
- (BOOL)shouldAutorotate{
return YES;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationPortrait;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
- (void)calculateFrameForFooterView{
//Caculate frame for footerView
[self addBarButton];
if(self.view.frame.size.width != frameClose.size.width){
frameClose = CGRectMake(0,footerView.frame.origin.y,self.view.frame.size.width,footerView.frame.size.height);
}
frameClose.origin.y = self.view.frame.size.height- footerView.frame.size.height;
CGFloat y;
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight){
NSLog(@"\n\n**(Landscap)self.view.frame.size(%@)",NSStringFromCGSize(self.view.frame.size));
frameClose.origin.y = self.view.frame.size.height- (footerView.frame.size.height);
y = self.view.frame.size.height-(KEYBOARD_HEIGHT+footerView.frame.size.height+TABBAR_HEIGHT+NAVIGATION_HEIGHT-20);
}else if(orientation == UIDeviceOrientationPortrait){
NSLog(@"\n\n**(Portrait)self.view.frame.size(%@)",NSStringFromCGSize(self.view.frame.size));
frameClose.origin.y = self.view.frame.size.height- (footerView.frame.size.height+TABBAR_HEIGHT+NAVIGATION_HEIGHT);
y = self.view.frame.size.height-(KEYBOARD_HEIGHT+TABBAR_HEIGHT+NAVIGATION_HEIGHT+footerView.frame.size.height);
}
frameOpen = CGRectMake(0,y,footerView.frame.size.width,footerView.frame.size.height);
}
答案 0 :(得分:2)
好吧,我在- (void)viewWillLayoutSubviews{}
解决了我的问题。
当我旋转设备时,这个方法调用两次。第二次,我收到确切的大小。
所以首先,我删除来自- (void)calculateFrameForFooterView
的{{1}}比将- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{}
放入- (void)calculateFrameForFooterView
所以,最后通过这样做解决了我的问题。然而,这个解决方案并不完美,但这对我有用。所以我不接受自己的答案,等待好的答案。
<强>感谢强>