gpt4 book ai didi

ios - 添加到 UINavigationItem 的 UIBarButton 未显示

转载 作者:行者123 更新时间:2023-11-29 03:22:01 24 4
gpt4 key购买 nike

我正在尝试向我的 iOS 应用程序添加一个栏按钮,但无法显示它。通过设置断点,我可以在导航项的 View 层次结构中看到该栏。如果有帮助,我选择了“嵌入导航 Controller ”。知道发生了什么吗?

UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(choosePreferredTerm:)];
[self.navItem setRightBarButtonItem:item animated:YES];

这是IB中的连接

Interface Builder

这是嵌入式导航 Controller 的样子: enter image description here这是它在 sim 上的样子: Simulator

最佳答案

试试这个而不是使用自定义导出“navItem”也确保您的应用程序有一个导航 Controller

        self.navigationItem.rightBarButtonItem = barButton;

关于ios - 添加到 UINavigationItem 的 UIBarButton 未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20945547/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com