【发布时间】:2014-01-30 05:43:54
【问题描述】:
我正在尝试制作一个带有导航栏(后退按钮、标题等)和标签栏(底部的工具栏)的应用程序。我正在使用子视图,所以我不必担心状态栏、导航栏、标签栏高度等。但我认为这给我带来了麻烦,因为我似乎无法弄清楚如何设置导航栏和标签栏.
这就是我所拥有的。我做错了什么?
AppDelegate.h
(default for single view app)
AppDelegate.m
(default for single view app)
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) UIView *contentSubview;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)loadView{}
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor greenColor];
self.contentSubview = [[UIView alloc] init];
self.contentSubview.backgroundColor = [UIColor orangeColor];
[view addSubview:self.contentSubview];
self.view = view;
}
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
self.contentSubview.frame = CGRectMake(
0,
self.topLayoutGuide.length,
CGRectGetWidth(self.view.frame),
CGRectGetHeight(self.view.frame)-self.topLayoutGuide.length-self.bottomLayoutGuide.length
);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
【问题讨论】:
-
这段代码与添加导航栏或工具栏有什么关系?您是想添加一个导航栏和工具栏,还是想要一个导航控制器?你想完成什么?
-
我想这就是我感到困惑的地方。我想添加一个导航栏和工具栏。但我正在使用子视图,所以我不确定是否必须做一些不同的事情。
标签: ios objective-c iphone swift xcode