cannot covert value type ‘TableViewController.Type’ to expected argument type ‘UIViewController’
我正在制作一个注册和登录的应用程序。我为此使用了 Parse。如果登录/注册成功,我想将视图控制器移动到 TableViewController。但是我收到此错误:”无法将值类型//’TableViewController.Type//’ 转换为预期的参数类型//’UIViewController//’。
这是我收到错误的行:
1
2 3 4 5 6 |
func logInViewController(logInController: PFLogInViewController, didLogInUser user: PFUser) { self.dismissViewControllerAnimated(true, completion: nil) self.presentViewController(TimelineTableViewController, animated: true, completion: nil) } |
这是完整的代码:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
// Created by Ojas Sethi on 12/10/15. // Copyright ? 2015 Jell Apps. All rights reserved. // import UIKit class LoginSignupViewController: UIViewController, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate { override func viewDidLoad() { override func viewDidAppear(animated: Bool) { if (PFUser.currentUser() == nil){ /*| PFLogInFields.LogInButton | PFLogInFields.SignUpButton | PFLogInFields.PasswordForgotten | PFLogInFields.DismissButton*/ let logoInLogoTitle = UILabel() self.logInViewController.logInView?.logo = logoInLogoTitle let signUpLogoTitle = UILabel() self.signUpViewController.signUpView?.logo = signUpLogoTitle override func didReceiveMemoryWarning() { func logInViewController(logInController: PFLogInViewController, didLogInUser user: PFUser) { func logInViewController(logInController: PFLogInViewController, didFailToLogInWithError error: NSError?) { func signUpViewController(signUpController: PFSignUpViewController, didSignUpUser user: PFUser) { } func signUpViewController(signUpController: PFSignUpViewController, didFailToSignUpWithError error: NSError?) { SignUpFaliedAlert() func signUpViewControllerDidCancelSignUp(signUpController: PFSignUpViewController) { func SignUpSuccessfulAlert(){ let doneAction = UIAlertAction(title:"Ok", style: .Default, handler: nil) alertController.addAction(doneAction) self.presentViewController(alertController, animated: true, completion: nil) func SignUpFaliedAlert(){ signUpalertFail = UIAlertController(title:"Failed", message:"Sorry! Sign up faield. Check the connections and try again later", preferredStyle: .Alert) let okAction = UIAlertAction(title:"Ok", style: .Default, handler: nil) signUpalertFail.addAction(okAction) self.presentViewController(signUpalertFail, animated: true, completion: nil) |
首先,您尝试从即将关闭的登录视图控制器中展示您的新视图控制器。那是不对的。您可能希望从提供登录视图控制器的稳定视图控制器中呈现它。这是关于如何做到这一点的好例子。这是基于objective-c的,所以请耐心等待。
其次,您需要创建一个
1
2 |
let timeLineTableVC = TimelineTableViewController()
self.presentViewController(timeLineTableVC, animated: true, completion: nil) |
您的(大写)
推荐的方法是在情节提要中为此控制器创建一个segue,然后在您想要呈现控制器时调用
最接近您的代码的方法是使用
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/268645.html