我想在屏幕左侧获取返回按钮,但我无法获取它

时间:2018-10-11 12:57:07

标签: ios swift uinavigationbar

{
    "name": "Python Attach (Remote Debug blah blah )",
    "type": "python",
    "request": "attach",
    "pathMappings": [
        {
            "localRoot": "${workspaceFolder}",  // You may also manually specify the directory containing your source code.
            "remoteRoot": "/home/pi/testdebug/" // Linux example; adjust as necessary for your OS and situation.
        }
    ],
    "port": 3000,                   // Set to the remote port.
    "host": "192.34.98.197"               // Set to your remote host's public IP address.
}

在视图上调用的我的后退按钮代码将显示功能

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

1 个答案:

答案 0 :(得分:0)

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]