按右栏按钮项目移动左栏按钮项目 [英] Pressing Right Bar Button Item Moves Left Bar Button Items

查看:21
本文介绍了按右栏按钮项目移动左栏按钮项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网络视图导航栏上有三个左栏按钮项.一个回到我的应用程序菜单和后退和前进按钮.我有一个右栏按钮可以打开一个活动视图控制器.当我按下右键时,左侧的前进和后退按钮会向下移动并离开导航栏.

I have three left bar button items on my web view nav bar. One that goes back to the the menu of my app and back and forward buttons. I have one right bar button that opens an activity view controller. When I press the right button, the forward and back buttons on the left get moved down and off of the nav bar.

- (void)viewDidLoad
{   
    leftBarButtonItems = [NSArray arrayWithObjects:@"Menu", @"Back", @"Forward", nil];

    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    NSString *urlAddress = @"http://www.littleheartrecords.com/releases.html";
    NSURL *url = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [webView loadRequest:requestObj];

    UIBarButtonItem *systemAction = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showMenu)];
    self.navigationItem.rightBarButtonItem = systemAction;

    UIBarButtonItem *openItem = [[UIBarButtonItem alloc] initWithTitle:@"Menu" style:UIBarButtonItemStylePlain target:self action:@selector(openButtonPressed)];
    self.navigationItem.leftBarButtonItem = openItem;

    UIImage *back = [UIImage imageNamed:@"back_arrow"];
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc]initWithTitle:@"" style: UIBarButtonItemStylePlain target:self action:@selector(GoBack)];
    [backButton setImage:back];

    UIImage *forward = [UIImage imageNamed:@"forward_arrow"];
    UIBarButtonItem *forwardButton = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleBordered target:self action:@selector(GoForward)];
    [forwardButton setImage:forward];

    self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:openItem, backButton, forwardButton, nil];
}

推荐答案

奇怪的是,对我有用的是将带有图像的按钮的标题设置为一个空格:

Strangely, what worked for me was setting the title of the buttons with images to a single space:

barButtonItem.title = @" ";
barButtonItem.image = [UIImage imageNamed:@"MenuIcon.png"];

这篇关于按右栏按钮项目移动左栏按钮项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆