gpt4 book ai didi

ios - 如何更改 "back"栏按钮项的标题?

转载 作者:搜寻专家 更新时间:2023-10-31 21:50:28 24 4
gpt4 key购买 nike

我想将“Root View Controller”后退按钮更改为“Back”而不更改 Root View Controller 的标题。

我已经尝试了这 3 个代码,但它们都不起作用。

navigationItem.backBarButtonItem?.title = "Back"
navigationItem.leftBarButtonItem?.title = "Back"
navigationItem.backBarButtonItem?.title = "Back"

我可以知道我做错了什么吗?提前致谢。

Screenshot

下面是整个方法的代码,供大家引用:

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

navigationItem.backBarButtonItem?.title = "Back"
navigationItem.leftBarButtonItem?.title = "Back"

manager = CLLocationManager()
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBest

if activePlace == -1
{
manager.requestWhenInUseAuthorization()
manager.startUpdatingLocation()
}
else
{
// print( "String(myvar3.dynamicType) -> \(places[activePlace]["lat"].dynamicType)")
let latitude = Double(places[activePlace]["lat"]!)
let longitude = Double(places[activePlace]["lon"]!)

//creating map region and annotation
createMapRegionAndAnnotation(latitude!, longitude: longitude!)

print(latitude)
}

最佳答案

尝试覆盖之前的屏幕转场

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let backItem = UIBarButtonItem()
backItem.title = "My title"
navigationItem.backBarButtonItem = backItem
}

关于ios - 如何更改 "back"栏按钮项的标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34396769/

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