このコードは、サーバーにデータを送信するための保存ボタンです。それが正常に送信された後。ビューコントローラをタブバーコントローラに戻してインデックス2に切り替える方法を教えてください。 .selectedIndexが機能していません。データをサーバーに正常に送信した後、タブバーのインデックスを切り替えるにはどうすればいいですか?
if (result == "success") {
self.view.endEditing(true)
let alert = UIAlertController(title: "Updated", message: "Update Successfully", preferredStyle: UIAlertControllerStyle.alert)
let okButton = UIAlertAction(title: "OK", style: UIAlertActionStyle.cancel, handler: nil)
alert.addAction(okButton)
self.present(alert, animated: true, completion: nil)
let appDelegate = UIApplication.shared.delegate! as! AppDelegate
let initialViewController =self.storyboard!.instantiateViewController(withIdentifier: "tabBarVC")
appDelegate.window?.rootViewController = initialViewController
appDelegate.window?.makeKeyAndVisible()
self.tabBarController?.selectedIndex = 2 // this code is not working
}
initialViewControllerの種類は何ですか? –
タブバーコントローラー –