我希望控制器同时具有后退按钮和菜单按钮,如同给定图像一样。amazon app
但问题是即使在增加x轴值后它也不会向右移动。因此,我无法添加返回按钮图像。这就是我现在正在做的事情。
button = [[UIButton alloc] initWithFrame:CGRectMake(200, 100, 100, 25)];
[button setImage:[UIImage imageNamed:@"menu.png"] forState:UIControlStateNormal];
[button addTarget:[SlideNavigationController sharedInstance] action:@selector(toggleLeftMenu) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
[SlideNavigationController sharedInstance].leftBarButtonItem = rightBarButtonItem;
答案 0 :(得分:0)
试试这个,
UIBarButtonItem *btnBack = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(back)];
UIBarButtonItem *btnMenu = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(menu)];
[self.navigationItem setLeftBarButtonItems:[NSArray arrayWithObjects:btnBack, btnMenu, nil]];
答案 1 :(得分:0)
在您的代码中,您专门用barBarButtonItem替换了后退按钮。
顺便说一下,你的命名有点令人困惑,你正在将rightBarButtonItem分配给navigationController的leftBarButtonItem。[SlideNavigationController sharedInstance].navigationItem.leftBarButtonItems= @[leftButton,menuButton]; // this will assign both button on the left side. same thing for rightBarButtonItems