这是我的故事板的图片:
带有注销按钮的视图控制器是我试图在导航栏(代码)中设置标题的地方:
import UIKitclass ProfileSettingsVIEwController: UIVIEwController { overrIDe func vIEwWillAppear(animated: Bool) { self.navigationItem.Title = "Profile Settings" } overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() self.navigationItem.leftbarbuttonItem = nil } overrIDe func dIDReceiveMemoryWarning() { super.dIDReceiveMemoryWarning() // dispose of any resources that can be recreated. } @IBAction func logoutbutton(sender: AnyObject) { PFUser.logout() var currentUser = PFUser.currentUser() self.performSegueWithIDentifIEr("userLoggedOut",sender: self) self.navigationController?.setNavigationbarHIDden(self.navigationController?.navigationbarHIDden == false,animated: true) }}
导航控制器中嵌入的视图控制器触发到标签栏控制器的segue:
import UIKitclass UserRegistrationVIEwController: UIVIEwController { func displayAlert(Title:String,error:String) { var alert = UIAlertController(Title: Title,message: error,preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(Title: "OK",style: .Default,handler: { action in })) self.presentVIEwController(alert,animated: true,completion: nil) } @IBOutlet var usernameTextFIEld: UITextFIEld! @IBOutlet var emailTextFIEld: UITextFIEld! @IBOutlet var passwordTextFIEld: UITextFIEld! overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() } overrIDe func dIDReceiveMemoryWarning() { super.dIDReceiveMemoryWarning() // dispose of any resources that can be recreated. } @IBAction func registerUser(sender: AnyObject) { var error = "" if usernameTextFIEld.text == nil || emailTextFIEld.text == nil || passwordTextFIEld.text == nil { error = "Please enter a username,email and password" } if error != "" { displayAlert("Error In Form",error: error) } else { var user = PFUser.currentUser() user.username = usernameTextFIEld.text user.password = passwordTextFIEld.text user.email = emailTextFIEld.text user.saveInBackgrounDWithBlock { (succeeded: Bool!,signupError: NSError!) -> VoID in if signupError == nil { println(user.username) println(user.password) println(user.email) self.performSegueWithIDentifIEr("successfulRegistration",sender: self) self.navigationController?.setNavigationbarHIDden(self.navigationController?.navigationbarHIDden == false,animated: true) // Hooray! Let them use the app Now. } else { if let errorString = signupError.userInfo?["error"] as? Nsstring { error = errorString } else { error = "Please try again later." } self.displayAlert("Could Not Sign Up",error: error) } } } }}解决方法 这对我有用:self.parent?.Title =“nav bar Title” 总结
以上是内存溢出为你收集整理的ios – Swift – 导航视图控制器不出现标题全部内容,希望文章能够帮你解决ios – Swift – 导航视图控制器不出现标题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)