iOS 添加导航栏两侧按钮

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"首页" style:UIBarButtonItemStyleBordered target:self action:@selector(popToRootView)] ;

    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"测试" style:UIBarButtonItemStyleBordered target:self action:@selector(test)] ;
//有时需要设置按钮大小才行

 

- (void)popToRootView{

    [self.navigationController popToRootViewControllerAnimated:YES];

}

- (void) test{

NSLog(@"test");

}

 

posted on 2015-12-15 19:37  大木哥  阅读(1835)  评论(0编辑  收藏  举报

导航