0

我有一个由我以编程方式创建的自定义 UINavigationcontroller。

问题在于 UINavigationBar 中默认的后退按钮在 IOS6 中看不到,但是当我按下它时,可以完成操作。

注意:返回按钮在 IOS5 中可见。

这是我用过的代码

- (void)customizeNavigationController:(UINavigationController *)navController
{
    UINavigationBar *navBar = [navController navigationBar];
    [navBar setTintColor:keyNavBarTintColor];

    UIImageView *myImageView = (UIImageView *)[navBar viewWithTag:keyNavBarBackgroundImageTag];
    if (myImageView == nil)
    {
      UIImage *img = [UIImage imageNamed:@"image.png"];
      CGRect rect = CGRectMake(0, 0, navBar.frame.size.width, navBar.frame.size.height);
      myImageView = [[UIImageView alloc] initWithFrame:rect];
      [myImageView setContentMode:UIViewContentModeScaleAspectFill];
      [myImageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
      myImageView.image = img;
      [myImageView setTag:keyNavBarBackgroundImageTag];
      [navBar addSubview:myImageView];
      [myImageView release];
    }
    self.navImageView = myImageView;
}
4

1 回答 1

0

尝试这个:

UIImage *image = [UIImage imageNamed:kButtonBackInActive];

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:image forState:UIControlStateNormal];
[button addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(0, 0, 39.0f, 44.0f)];
button.contentEdgeInsets = (UIEdgeInsets){.left=-8};
button.showsTouchWhenHighlighted = NO;

UIBarButtonItem * backbutton = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease];
[self.navigationItem setLeftBarButtonItem:backbutton];
于 2012-10-01T11:08:47.750 回答