[英]iOS Storyboard, trying to add bar button item as back button not appearing
I created a UIViewController and I added a UIBarButtonItem to represent a back button and its not appearing when I run my app, just a blank screen. 我创建了一个UIViewController,并添加了一个UIBarButtonItem来表示后退按钮,当我运行我的应用程序时,该按钮没有出现,只是一个空白屏幕。
Here is a screen shot of my scene 这是我的场景的屏幕截图
and here is the list of items in my scene: 这是我场景中的项目列表:
I also connected the bar button item to my header file: 我也将bar按钮项连接到我的头文件:
@property (strong, nonatomic) IBOutlet UIBarButtonItem *BackButtonItem;
still not appearing 仍然没有出现
The button is appearing as you can see the item button on the lower left hand of your screen. 随即出现该按钮,您可以在屏幕的左下方看到项目按钮。
To create a custom back button I would embed a Navigation Controller inside of your View Controller. 为了创建一个自定义的后退按钮,我将在您的View Controller中嵌入一个Navigation Controller。 Then inside your .m file you can do the following, if you want a custom back button with a custom image.
然后,如果要使用带有自定义图像的自定义后退按钮,则可以在.m文件中执行以下操作。
- (void)viewDidLoad
{
UIBarButtonItem *addCustomButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"YourImage.png"] style:UIBarButtonItemStylePlain target:self action:@selector(yourSelector:)];
self.navigationItem.leftBarButtonItem = @[addCustomButton];
}
To add a back button in view controller through storyboard, follow the below steps:- 要通过情节提要在视图控制器中添加后退按钮,请执行以下步骤:-
Check this image, it will clear your all doubts. 检查此图像,它将清除您的所有疑问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.