gpt4 book ai didi

ios - 我想获取屏幕左侧的后退按钮,但无法获取它

转载 作者:行者123 更新时间:2023-11-30 11:05:43 25 4
gpt4 key购买 nike

file:///Users/anuragpanchal/Desktop/Simulator%20Screen%20Shot%20-%20iPhone%208%20Plus%20-%202018-10-11%20at%2014.18.24.png

我在 View 上调用的后退按钮代码将出现 func

//MARK: Navigation button
func backNavigationButton() {
let button1 = UIBarButtonItem(image: UIImage(named: "back.png"), style: .plain, target: self, action: #selector(actionBackButton)) //
self.navigationItem.leftBarButtonItem = button1

}

@objc func actionBackButton() {
// PopToHome()
self.navigationController?.popViewController(animated: true)
}

最佳答案

早期版本的 iOS 使用此代码:

let leftBarItem = UIBarButtonItem(image: leftImage, style: .done, target: target, action: leftImageSelector)

对于 iOS 11 或更高版本,您需要添加一个间隔符,因为苹果更改了按钮的布局:

let spacer = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.fixedSpace, target: self, action: nil)
spacer.width = 5
self.navigationItem.leftBarButtonItems = [spacer, leftBarItem]

关于ios - 我想获取屏幕左侧的后退按钮,但无法获取它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52760637/

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