【问题标题】:iOS7 - Navigation Controller - Custom Back ButtoniOS7 - 导航控制器 - 自定义后退按钮
【发布时间】:2014-03-18 00:34:10
【问题描述】:

我需要为我的新 iOS 7 应用使用自定义后退按钮图像。当我使用 Storyboard 并使用属性检查器添加图像时,这就是 XCode 为我呈现的内容:

有人知道导航控制器为什么会这样吗?我经常将@2x PNG 图像放入表格视图中的条形按钮项(在导航项下)。

@interface MEDevicesViewController : UITableViewController

在我的应用程序中,我使用ECSlidingViewController,并且在导航控制器中有表格视图。这是在我的导航控制器上。

任何帮助表示赞赏...

【问题讨论】:

  • @interface MEDevicesViewController : UITableViewController 没有相关性。显示一些真实的代码。

标签: objective-c ios7 uinavigationcontroller storyboard uinavigationbar


【解决方案1】:
UIButton * button= [UIButton buttonWithType:UIButtonTypeCustom];

[button setFrame:CGRectMake(0, 0, 51, 31)];
[button setImage:[UIImage imageNamed:@"back_btn.png"]forState:UIControlStateNormal];
[button addTarget:self 
          action:@selector(backbtnpressed:)            
 forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *barButton  = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.leftBarButtonItem = barButton;


-(IBAction)backbtnpressed:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-09
    • 2011-11-29
    相关资源
    最近更新 更多