相关疑难解决方法(0)

以编程方式添加导航栏iOS

我正在尝试使用导航栏(后退按钮,标题等)和标签栏(底部的工具栏)制作应用程序.我正在使用子视图,所以我不必担心状态栏,导航栏,标签栏高度等.但我认为这给我带来麻烦,因为我似乎无法弄清楚如何设置导航和标签栏.

这就是我所拥有的.我究竟做错了什么?

AppDelegate.h

(default for single view app)
Run Code Online (Sandbox Code Playgroud)

AppDelegate.m

(default for single view app)
Run Code Online (Sandbox Code Playgroud)

ViewController.h

#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) UIView *contentSubview;
@end
Run Code Online (Sandbox Code Playgroud)

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 …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c ios swift

25
推荐指数
1
解决办法
6万
查看次数

标签 统计

ios ×1

iphone ×1

objective-c ×1

swift ×1

xcode ×1