ios - 导航栏按钮未显示

标签 ios iphone uinavigationcontroller

我有一个 View Controller ,我有导航栏。
我已将其色调设置为白色。现在我从该 View Controller 展示图像选择器 View 和 Paypal 页面。
当图像选择器 View 或 Paypal View 出现时,其导航栏不显示按钮(默认为取消按钮)。
按钮在那里,但它的颜色设置为白色。如何解决这个问题?我可以更改图像选择器 View 的颜色吗?
我正在显示这样的导航栏:

 PaymentViewController *paymentVC=[[PaymentViewController alloc]initWithNibName:@"PaymentViewController" bundle:nil];
 UINavigationController *navController=[[UINavigationController alloc]initWithRootViewController:paymentVC];
 if ([navController.navigationBar respondsToSelector:@selector( setBackgroundImage:forBarMetrics:)])
 {
       UIImage *navBarImg = [UIImage imageNamed:@"top_bar"];
       [navController.navigationBar setBackgroundImage:navBarImg forBarMetrics:UIBarMetricsDefault];
 }
 [self.tabBar presentViewController:navController animated:NO completion:nil];

最佳答案

改为编写以下代码:

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed: @"top_bar"] forBarMetrics:UIBarMetricsDefault];
PaymentViewController *paymentVC=[[PaymentViewController alloc]initWithNibName:@"PaymentViewController" bundle:nil];
UINavigationController *navController=[[UINavigationController alloc]initWithRootViewController:paymentVC];
[self.tabBar presentViewController:navController animated:NO completion:nil];

关于ios - 导航栏按钮未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20867143/

相关文章:

swift - 使用 Swift 以编程方式创建的 UIBarButtonItem,不可见

iOS 状态恢复和 UINavigationController 模态视图

ios - swift 类和 Objective -c Viewcontrollers 之间的通知中心网络

ios - ScrollView 中的 WKWebView

ios - 为什么 UITableView 单元格在滚动时重叠?

iphone - Facebook 图形 API 与 native iPhone 应用程序

ios - 以编程方式创建不是 rootViewController 的 UINavigationController

iOS Objective-C 如何获得 2 位小数四舍五入的浮点值?

ios - 如何快速创建带有分钟和秒的倒数计时器?

iphone - 自定义书签图标添加到 UISearchBar