gpt4 book ai didi

ios - 导航栏在 iPhone 4 (iOS 7.1.2) 中消失

转载 作者:行者123 更新时间:2023-11-29 12:14:29 27 4
gpt4 key购买 nike

这可能是一个小问题,但我不知道哪里出了问题。当我在 iPhone 4s 到 6+ 的模拟器上运行时,它工作正常。

enter image description here

但是当我在 iPhone 4 (iOS 7.1.2) 上运行时,红色导航栏消失了。

这是我的代码

  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[[UINavigationBar appearance]setBarTintColor:[UIColor redColor]];
}

更多详情

1) 我正在使用 show segue from previous view 进入这个屏幕。

2) 这个屏幕是我在 Storyboard 中制作的。(我也检查了约束,但所有约束都是正确的)我没有在 Storyboard 中给出任何导航栏。此外,我没有通过编程方式在 Controller 中隐藏导航栏。

3)我也试过了

//    UINavigationBar *navbar = [[UINavigationBar   alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)];
// [navbar setBackgroundColor:[UIColor yellowColor]];
// [self.view addSubview:navbar];

在 viewDidLoad 和 viewDidAppear 中,但它不工作。

谁能帮帮我?

根据一些建议,我尝试更新 viewDidLoad、viewDidAppear 中的以下代码(部署目标为 7.1)

 if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
self.edgesForExtendedLayout = UIRectEdgeNone;
}


UINavigationBar *navbar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 55)];
[navbar setBackgroundColor:[UIColor yellowColor]];

self.navigationController.navigationBar.translucent = NO;

[self.view addSubview:navbar];

UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 19, 20)];
[button addTarget:self action:@selector(didTapBackBtn:) forControlEvents:UIControlEventTouchUpInside];
[button setImage:[UIImage imageNamed:@"arrow.png"] forState:UIControlStateNormal];
UIBarButtonItem *backBarButton = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.leftBarButtonItem = backBarButton;

面临同样的问题。

最佳答案

花了更多时间后,我得到了解决方案 enter image description here

每当有从一个 VC 到另一个 VC 的 Show segue 时,就像上面那样。然后是UINavigation条码

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[[UINavigationBar appearance]setBarTintColor:[UIColor redColor]];
}

不适用于 iOS 7.1(在我的例子中,它发生在 Buy voucher 第二个 View Controller 上)。

所以我只是删除了 segue 并使用了下一个屏幕

- (IBAction)didTapOnNext:(id)sender
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
BuyVaucherSecondViewController *bvs = [storyboard instantiateViewControllerWithIdentifier:@"buyVaucherSecond"];
[self.navigationController pushViewController:bvs animated:YES];
}

然后它对我有用,导航栏显示为 iOS 7.1。 :)

关于ios - 导航栏在 iPhone 4 (iOS 7.1.2) 中消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32327453/

27 4 0