简体   繁体   English

iOS 7中的UINavigationController后退按钮V形

[英]UINavigationController Back Button Chevron in iOS 7

I would love to say that I'm enjoying this transition to iOS 7, but it feels like battle after battle to just get the app functional again. 我想说的是,我很享受向iOS 7的过渡,但感觉就像是一场又一场的战斗,只是再次使该应用程序正常工作。

My current issue is with a uinavigationcontroller. 我当前的问题是与uinavigationcontroller有关。 It's embedded in a tab controller. 它嵌入在选项卡控制器中。 The problem occurs when the user starts drilling down into categories. 当用户开始向下钻取类别时,就会出现此问题。 The back button chevron moves to the upper left portion of the navigation bar while the actual back button remains fixed in its normal spot. 后退按钮V形框移动到导航栏的左上部分,而实际的后退按钮保持固定在其正常位置。 The code isn't doing any manipulation. 代码没有做任何操作。 It's just pushing and popping view controllers. 它只是推和弹出视图控制器。

Here's a screenshot of the issue: 这是问题的屏幕截图:

在此处输入图片说明

Has anyone encountered this problem and have any ideas how I may fix it? 有没有人遇到过这个问题,并且对如何解决这个问题有任何想法? All suggestions are welcome. 欢迎所有建议。

Have you changed the font size - this may have changed the line-height value causing displacement? 您是否更改了字体大小-这可能已更改了导致位移的行高值?

It maybe best to opt for a custom back button so you have more control of the placement. 最好选择自定义后退按钮,以便您可以更好地控制展示位置。 You can place this snippet in viewDidLoad 您可以将此片段放在viewDidLoad中

if ( [self.navigationController.viewControllers count] > 1 )
{
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setAdjustsImageWhenHighlighted:NO];
    [backBtn setShowsTouchWhenHighlighted:YES];
    [backBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
    UIImage *backBtnImage = [UIImage imageNamed:@"back.png"]; // <-- Use your own image
    [backBtn setImage:backBtnImage forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
    backBtn.frame = CGRectMake(0, 0, 40, 40);
    UIBarButtonItem *backBarBtnItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
    self.navigationItem.leftBarButtonItem = backBarBtnItem;
}

Also add the method for custom back button touch event: 还添加自定义后退按钮触摸事件的方法:

- (void)goBack
{
    [self.navigationController popViewControllerAnimated:YES];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM