简体   繁体   English

导航栏项目图像不可见

[英]Navigation Bar Item Image is not visible

I trying to implement a hamburger menu using a scroll view, two container views and two embedded views with Swift 2 and Xcode 7. Everything works but for some reason, I can't see the picture of the Navigation Item I set. 我尝试使用Swift视图和Swift 2和Xcode 7来使用滚动视图,两个容器视图和两个嵌入式视图来实现汉堡菜单。一切正常,但由于某些原因,我看不到我设置的Navigation Item的图片。 However if I click on the area where the Item is supposed to be it responds as I expect. 但是,如果我单击该项目应为的区域,它将响应我的预期。 But I can't figure out why I can see the Nav bar item image? 但是我不知道为什么我可以看到导航栏项目图像?

Any idea what I am doing wrong? 知道我在做什么错吗? Thanks 谢谢

Be sure that the image that you're trying to set is added to your project. 确保将您要设置的图像添加到项目中。 Not the project folder but the actual Xcode project and used in the target that you're currently using. 不是项目文件夹,而是实际的Xcode项目,并且已在当前使用的目标中使用。 My guess is that you're setting the image with 我的猜测是您正在使用

UIImage(named:"YourImageName")

Also, another hint is that you can make your button visible. 另外,另一个提示是您可以使按钮可见。

Hope this helps. 希望这可以帮助。

I figured out my bug. 我发现了我的错误。 I had copy a piece of code to create the menu image and paste it in a class with the same name. 我复制了一段代码来创建菜单图像,并将其粘贴到具有相同名称的类中。 So the image was never created. 因此,该映像从未创建。 But Xcode didn't complained that I have a nested class of the same name as the main class, that would have helped so much :-/ 但是Xcode并没有抱怨我有一个与主类同名的嵌套类,这将有很大帮助:-/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM