ios - 导航项在 iPhone 5S/5C 尺寸上不显示

标签 ios swift uinavigationcontroller uinavigationbar uinavigationitem

我有以下代码片段,用于在导航栏的右上角添加“下一步”按钮。

let next = UIButton()
next.setTitle("Next", for: .normal)
next.addTarget(self, action: #selector(nextButtonHandler), for: .touchUpInside)
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: next)

这在普通尺寸的手机上显示得很好,但在我的 5C 上却不行...我不明白为什么..我在设置右栏按钮项目的位置放置了一个断点,它不是零..救命!

最佳答案

使用这个:

  1. let barButton = UIBarButtonItem(标题: , 样式: , 目标: , 操作: )
  2. 将按钮添加到navigationController

super 简单

关于ios - 导航项在 iPhone 5S/5C 尺寸上不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49247933/

相关文章:

swift - 用于 Swift 编码的 iOS 应用程序的 Ffmpeg

ios - 关闭 View Controller 意外行为

c++ - 来自 Grand Central Dispatch 的 dispatch_async() 和来自 C++11 的 std::async

IOS:检查 NSString 的一部分

ios - 为什么下面的 Core Animation 隐式动画不起作用?

ios - 重用 Table View 变量 Swift

json - 我需要创建一个带有嵌套 Json 的 TableView

ios - 如何在导航 Controller 中的 segues 之间移动?

Swift - TabBarController - 在运行时决定 segue

ios - 在开始新的异步操作之前,快速等待现有的异步操作完成