【发布时间】:2015-12-31 07:18:36
【问题描述】:
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);
}
【问题讨论】:
-
你在 detailViewController 上尝试过 self.view.frame.size
-
@satheesh,我尝试使用 self.view.frame.size 和 self.view.bounds.size 但没有得到正确的值..
-
那么你的输出是什么??
-
@satheesh,请检查我的“编辑”,这可能会提供线索
标签: objective-c ipad ios8 uisplitviewcontroller