我现在所拥有的是(uibarbuttonitem连接到头文件中的那个)
然后我按照下面的方式进行自定义
- (void)viewDidLoad
{
[super viewDidLoad];
UIButton *back = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 55, 32)];
[back setBackgroundImage:[UIImage imageNamed:@"back_button01.png"] forState:UIControlStateNormal];
[back setTitle:@"Back" forState:UIControlStateNormal];
[back addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
backButton = [[UIBarButtonItem alloc] initWithCustomView:back];
}
然而,在运行我的应用程序后,uibarbuttonitem根本没有改变。我确实尝试将上面的代码放在initWithNibname
中,但根本没有运气
请指教我,并指出我是否在中间犯了错误
答案 0 :(得分:2)
最后你需要self.navigationItem.leftBarButtonItem = backButton;
。