【问题标题】:UINavigationBar does not show on second ViewController on Apple TVUINavigationBar 未显示在 Apple TV 上的第二个 ViewController 上
【发布时间】:2015-12-28 12:19:56
【问题描述】:

我在 AppDelegate 中有以下代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    UIStoryboard* sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController* viewController = [sb instantiateViewControllerWithIdentifier:@"ViewController"];

    UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];

    UILabel* topBar = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 30)];
    topBar.text = @"Custom Navigation";

    [navigationController.navigationBar.topItem setTitleView:topBar];

    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [self.window setRootViewController:navigationController];
    [self.window makeKeyAndVisible];
    return YES;
}

当点击按钮时,运行以下代码;

UIStoryboard* sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController* second = [sb instantiateViewControllerWithIdentifier:@"second"];
[self.navigationController setNavigationBarHidden:NO];
[self.navigationController pushViewController:second animated:YES];

导航栏始终隐藏在第二个屏幕上。我尝试了[self.navigationController setNavigationBarHidden:NO][self.navigationController.navigationBar setHidden:NO],但它不起作用。

我的代码在 iPhone 或 iPad 上成功运行,但在 Apple TV 上无法运行。 第二屏显示导航栏的解决方法是什么?

【问题讨论】:

    标签: uinavigationcontroller apple-tv


    【解决方案1】:

    不要在 Apple TV 上使用 UINavigationBar。 UITabBar 更有用。如果您制作自定义标签栏,请在您的界面中实现 UITabBarController 并将休闲代码写入 viewDidLoad 方法。

     customView = [[[NSBundle mainBundle] loadNibNamed:@"CustomTopBar" owner:self        options:nil] objectAtIndex:0];
    [self.view addSubview: customView];
    

    【讨论】:

      猜你喜欢
      • 2012-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多