diff --git a/_includes/ios/user-interface.md b/_includes/ios/user-interface.md index d44c30cf7..e83799b5e 100644 --- a/_includes/ios/user-interface.md +++ b/_includes/ios/user-interface.md @@ -21,7 +21,7 @@ logInController.delegate = self; ```swift var logInController = PFLogInViewController() logInController.delegate = self -self.presentViewController(logInController, animated:true, completion: nil) +self.present(logInController, animated:true, completion: nil) ``` @@ -48,11 +48,11 @@ Any of the above features can be turned on or off. The options can be set using | PFLogInFieldsDismissButton); ``` ```swift - logInController.fields = [PFLogInFields.UsernameAndPassword, - PFLogInFields.LogInButton, - PFLogInFields.SignUpButton, - PFLogInFields.PasswordForgotten, - PFLogInFields.DismissButton] +logInController.fields = [PFLogInFields.usernameAndPassword, + PFLogInFields.logInButton, + PFLogInFields.signUpButton, + PFLogInFields.passwordForgotten, + PFLogInFields.dismissButton] ``` @@ -72,9 +72,9 @@ logInController.fields = (PFLogInFieldsUsernameAndPassword | PFLogInFieldsTwitter); ``` ```swift -logInController.fields = [PFLogInFields.UsernameAndPassword, - PFLogInFields.Facebook, - PFLogInFields.Twitter] +logInController.fields = [PFLogInFields.usernameAndPassword, + PFLogInFields.facebook, + PFLogInFields.twitter] ``` @@ -91,7 +91,7 @@ logInController.facebookPermissions = @[ @"friends_about_me" ]; var logInController = PFLogInViewController() logInController.delegate = self logInController.facebookPermissions = [ "friends_about_me" ] -self.presentViewController(logInController, animated:true, completion:nil) +self.present(logInController, animated:true, completion:nil) ``` @@ -112,11 +112,11 @@ When the user signs in or cancels, the `PFLogInViewController` notifies the dele ``` ```swift func logInViewController(controller: PFLogInViewController, didLogInUser user: PFUser!) -> Void { - self.dismissViewControllerAnimated(true, completion: nil) + self.dismiss(animated: true, completion: nil) } -func logInViewControllerDidCancelLogIn(controller: PFLogInViewController) -> Void { - self.dismissViewControllerAnimated(true, completion: nil) +func logInViewControllerDidCancelLog(in controller: PFLogInViewController) -> Void { + self.dismiss(animated: true, completion: nil) } ``` @@ -146,15 +146,15 @@ You might want to use your own logo or background image. You can achieve this by @end ``` ```swift -class MyLogInViewController : PFLogInViewController { +class MyLogInViewController: PFLogInViewController { override func viewDidLoad() { super.viewDidLoad() - self.view.backgroundColor = UIColor.darkGrayColor() + self.view.backgroundColor = .darkGray - let logoView = UIImageView(image: UIImage(named:"logo.png")) - self.logInView.logo = logoView + let logoView = UIImageView(image: UIImage(named:"logo.png")) + self.logInView?.logo = logoView } } @@ -172,7 +172,7 @@ logInController.signUpController = [[MySignUpViewController alloc] init]; ```swift let logInController = MyLogInViewController() logInController.signUpController = MySignUpViewController() -self.presentViewController(logInController, animated: true, completion: nil) +self.present(logInController, animated: true, completion: nil) ``` @@ -272,11 +272,7 @@ signUpController.fields = (PFSignUpFieldsUsernameAndPassword | PFSignUpFieldsDismissButton); ``` ```swift -signUpController.fields = [PFSignUpFields.usernameAndPassword, - PFSignUpFields.signUpButton, - PFSignUpFields.email, - PFSignUpFields.additional, - PFSignUpFields.dismissButton] +signUpController.fields = [.usernameAndPassword, .signUpButton, .email, .additional, .dismissButton] ``` @@ -298,11 +294,11 @@ When the user signs up or cancels, the `PFSignUpViewController` notifies the del ``` ```swift func signUpViewController(signUpController: PFSignUpViewController, didSignUpUser user: PFUser) -> Void { - self.dismissViewControllerAnimated(true, completion: nil) + self.dismiss(animated: true, completion: nil) } func signUpViewControllerDidCancelSignUp(signUpController: PFSignUpViewController) -> Void { - self.dismissViewControllerAnimated(true, completion: nil) + self.dismiss(animated: true, completion: nil) } ``` @@ -338,10 +334,10 @@ class MySignUpViewController : PFSignUpViewController { override func viewDidLoad() { super.viewDidLoad() - self.view.backgroundColor = UIColor.darkGrayColor() + self.view.backgroundColor = .darkGray - let logoView = UIImageView(image: UIImage(named: "logo.png")) - self.signUpView.logo = logoView // 'logo' can be any UIView + let logoView = UIImageView(image: UIImage(named: "logo.png")) + self.signUpView?.logo = logoView // 'logo' can be any UIView } } ``` @@ -360,12 +356,12 @@ Often you will want to run some client-side validation on the sign up informatio } ``` ```swift -func signUpViewController(signUpController: PFSignUpViewController!, - shouldBeginSignUp info: [NSObject : AnyObject]!) -> Bool { - if let password = info?["password"] as? String { - return password.utf16Count >= 8 - } - return false +func signUpViewController(_ signUpController: PFSignUpViewController, + shouldBeginSignUp info: [String : String]) -> Bool { + if let password = info["password"] { + return password.utf16.count >= 8 + } + return false } ``` `info` is a dictionary that contains all sign up fields, such as username, password, email, and additional. @@ -400,20 +396,20 @@ class MySignUpViewController : PFSignUpViewController { override func viewDidLoad() { super.viewDidLoad() - self.signUpView.usernameField.placeholder = "phone" + self.signUpView?.usernameField?.placeholder = "phone" } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() - self.signUpView.signUpButton.frame = CGRectMake(...) // Set a different frame. + self.signUpView?.signUpButton?.frame = CGRectMake(...) // Set a different frame. } } ``` -Developer interested in this kind of customization should take a look at the interface of [`PFSignUpView`](http://parseplatform.org/Parse-SDK-iOS-OSX/api/Classes/PFSignUpView.html), where all customizable properties are documented. +Developers interested in this kind of customization should take a look at the interface of [`PFSignUpView`](http://parseplatform.org/Parse-SDK-iOS-OSX/api/Classes/PFSignUpView.html), where all customizable properties are documented. ### Portrait and Landscape