gpt4 book ai didi

IOS navigationController?.popToRootViewController有错

转载 作者:搜寻专家 更新时间:2023-11-01 07:13:57 25 4
gpt4 key购买 nike

@IBAction func addInformation(_ sender: UIBarButtonItem) {
// check rateHourly has value
if let editedRateHourly = rateHourly.text {
print("editedRateHourly condition is \(editedRateHourly)")
if editedRateHourly != ""{
print("not nil")
// check edit value is number?
let num = Int(editedRateHourly)
if num != nil {
print("is num")
// add to database
UserDefaults.standard.set(editedRateHourly, forKey: "\(findDate())")
UserDefaults.standard.synchronize()
// back to last viewController
navigationController?.popToRootViewController(animated: true)
}else{
print("not num")
print("error alert push!!")
popErrorAlert()
}
}else {
print("nil")
print("editedRateHourly condition is nil")
popErrorAlert()
}
}
}
@IBAction func cannelInformationPage(_ sender: UIBarButtonItem) {
navigationController?.popToRootViewController(animated: true)
}

我想创建一个新的简单编辑页面。这对我来说是两个问题,当我完成版本时,if-else 将检查条件是否正确,然后保存数据 popToRootViewControlle。当我完成编辑时,我单击“addInformation”BarButtonItem,但我的 UI 出错了。另一个错误是当我点击 editField 但我没有输入任何条件时。然后我点击“cannelInformationPage”UIBarButtonItem。它也会出错。

It's what I get wrong

wrong information

最佳答案

因为它返回 Bool

_ = navigationController?.popToRootViewController(animated: true)

关于IOS navigationController?.popToRootViewController有错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43314743/

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