在视图控制器上添加导航栏

我在iOS上是新的,我想添加一个导航栏在我的视图控制器与左边的2个button和订阅权。 我没有任何线索如何做到这一点..现在我刚从界面生成器添加了一个导航栏,创build一个(强)refrnce在.h文件中,并做了以下编码。

navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 20, 1026, 50)]; [navBar setTintColor:[UIColor clearColor]]; [navBar setBackgroundColor:[UIColor redColor]]; [navBar setDelegate:self]; [self.view addSubview:navBar]; UIBarButtonItem *bi1 = [[UIBarButtonItem alloc] initWithTitle:@"subscribe" style:UIBarButtonItemStyleBordered target:self action:@selector(editBotton)]; bi1.style = UIBarButtonItemStyleBordered; bi1.tintColor =[UIColor colorWithWhite:0.305f alpha:0.0f]; self.navigationItem.rightBarButtonItem = bi1; 

但nothings发生..请帮助

你可以在AppDelegate中添加,

  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"                                                             bundle: nil];    SampleViewController *mainViewController = (SampleViewController*)[mainStoryboard                                                       instantiateViewControllerWithIdentifier: @"SampleViewController"];    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mainViewController];    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    [self.window setRootViewController:navigationController];    [self.window setBackgroundColor:[UIColor whiteColor]];    [self.window makeKeyAndVisible];    return YES; }