【发布时间】:2014-01-13 08:50:12
【问题描述】:
希望,第三次幸运:
只是尝试让内容显示在导航栏下方和标签栏上方(没有任何内容,也显示在下方)。
我已经尝试了几乎所有方法,但无济于事。
在 rootController 中使用以下代码,我只是想获得一个视图(红色边框有助于显示它是否正常工作):
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
UIView *view1 = [[UIView alloc] initWithFrame:self.view.frame];
view1.layer.borderColor = [UIColor redColor].CGColor;
view1.layer.borderWidth = 2.0f;
[self.view addSubview:view1];
}
设置如下:
- (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;
进入视图控制器,我得到:
半透明条,导航栏下方的红色边框正确位置,但tabBar下方的底部边框。
我相信我已经尝试了所有组合和所有想法。
谁能告诉我如何在不使用界面生成器的情况下让内容适合导航栏下方、标签栏上方。
提前致谢。
【问题讨论】:
标签: ios objective-c ios7 uinavigationcontroller uitabbarcontroller