简体   繁体   English

为什么我不能通过Interface Builder将左栏按钮项添加到导航项?

[英]Why I can't add left bar button item to Navigation Item through Interface Builder?

It only allows me to add the right barbutton, but when I drag another barbuttonitem, it's simply denied. 它只允许我添加正确的按钮,但是当我拖动另一个barbuttonitem时,它被简单地拒绝了。 I looked at the properties of NavigationItem, and I saw that there are outlets for right barbutton and even for the back barbutton. 我查看了NavigationItem的属性,我看到有正确的按钮,甚至是后面的按钮。 So: why can't I add a left barbutton item to the Navigation Item (through Interface Builder)? 那么:为什么我不能在导航项中添加左栏按钮项(通过Interface Builder)?

Yeah, using it programatically is probably (way) better. 是的,以编程方式使用它可能(方式)更好。 Use [self.navigationController pushViewController:<otherviewname> animated:YES]; 使用[self.navigationController pushViewController:<otherviewname> animated:YES]; This way, in the next view, there is a backbutton to this screen added automatically (unless you decide to hide the backbutton programatically in that next view, but that's a whole different story). 这样,在下一个视图中,会自动添加此屏幕的后退按钮(除非您决定在下一个视图中以编程方式隐藏后退按钮,但这是一个完全不同的故事)。 The advantage of pushViewController instead of modalTransitionView is that navigation-options are so easily added! pushViewController而不是modalTransitionView的优点是导航选项很容易添加!

如果在视图属性中定义了按钮,则似乎无法向导航栏添加按钮,但是如果从对象库添加导航栏,则可以添加按钮(左侧和右侧)。

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

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