我已经按照我在网上找到的信息进行了操作,并且我设法显示了该按钮,但是当我单击它时,什么也没有发生。我是 iOS 编程新手,我不确定我是否做错了什么。
UIImage *backImage = [UIImage imageNamed:@"backIcon.PNG"];
// create the button and assign the image to the button
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[backButton setImage:backImage forState:UIControlStateNormal];
backButton.frame = CGRectMake(0, 0, backImage.size.width, backImage.size.height);
[backButton addTarget:self action:@selector(goBack:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customBarButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.hidesBackButton = YES;
self.navigationItem.leftBarButtonItem = customBarButton;
这个按钮的代码
- (void)goBack:(id)sender {
[self.navigationController popViewControllerAnimated:YES]; }
谢谢