Ios 选项卡栏和导航栏视图部分隐藏
希望第三次幸运: 只需尝试让内容显示在导航栏下方和选项卡栏上方(如果没有内容,则显示在下面) 我几乎什么都试过了,都没用 在rootController中使用以下代码,我只是想在其中创建一个视图(红色边框有助于显示它是否工作): 设置为:Ios 选项卡栏和导航栏视图部分隐藏,ios,objective-c,ios7,uinavigationcontroller,uitabbarcontroller,Ios,Objective C,Ios7,Uinavigationcontroller,Uitabbarcontroller,希望第三次幸运: 只需尝试让内容显示在导航栏下方和选项卡栏上方(如果没有内容,则显示在下面) 我几乎什么都试过了,都没用 在rootController中使用以下代码,我只是想在其中创建一个视图(红色边框有助于显示它是否工作): 设置为: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
TSTFirstViewController *rootController = [[TSTFirstViewController alloc] init];
rootController.title = @"Hello World";
UINavigationController *firstRootController = [[UINavigationController alloc] initWithRootViewController:rootController];
NSArray *viewControllers = @[firstRootController];
UITabBarController *tabBar = [[UITabBarController alloc] init];
tabBar.viewControllers = viewControllers;
tabBar.tabBar.barStyle = UIBarStyleBlack;
tabBar.tabBar.translucent = NO;
[self.window setRootViewController:tabBar];
[self.window makeKeyAndVisible];
return YES;
}
我得到:
如果我将两行添加到我的AppDelegate
:
firstRootController.navigationBar.translucent = NO;
firstRootController.navigationBar.barStyle = UIBarStyleBlack;
一切都变得非常混乱:
红色边框向下移动,底部边框消失在选项卡栏下方。出现一个大的空白
如果删除半透明线并添加:
self.edgesForExtendedLayout = UIRectEdgeNone;
在视图控制器中,我得到:
半透明栏,红色边框位于导航栏下方的正确位置,但底部边框位于选项卡栏下方
我相信我已经尝试了所有的组合,所有的想法
有谁能告诉我如何在不使用Interface Builder的情况下将内容放在导航栏下方、选项卡栏上方
提前谢谢。是的,这是您的解决方案 使用self.edgesForExtendedLayout=UIRectEdgeNone时代码>请考虑iOS 7中的三件事情:
导航栏
状态栏
(时间、网络、电池显示在顶部)TabBar
UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height-self.navigationController.navigationBar.frame.size.height-self.navigationController.tabBarController.tabBar.frame.size.height-[UIApplication sharedApplication].statusBarFrame.size.height)];
view1.layer.borderColor = [UIColor redColor].CGColor;
view1.layer.borderWidth = 2.0f;
[self.view addSubview:view1];
下面是使用此代码的附加屏幕
我希望这能有所帮助。非常感谢您的帮助。。。但我忍不住想知道是否还有比这更简单的事情?我本以为使用
self.edgesForExtendedLayout
可以使视图相应地适合,而不必计算所有单个组件的高度。
UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height-self.navigationController.navigationBar.frame.size.height-self.navigationController.tabBarController.tabBar.frame.size.height-[UIApplication sharedApplication].statusBarFrame.size.height)];
view1.layer.borderColor = [UIColor redColor].CGColor;
view1.layer.borderWidth = 2.0f;
[self.view addSubview:view1];