ios - 使用 Storyboard自定义 Parse PFLoginViewController 的布局?

标签 ios objective-c parse-platform xcode-storyboard pfloginviewcontroller

我正在使用 parse 构建一个应用程序,我想知道是否可以使用 Storyboard直观地自定义 PFLoginViewController 的外观和布局?我知道可以对其进行子类化并使用代码对其进行自定义,但如果可能的话,我更愿意以可视化方式进行?

最佳答案

视觉上是不可能做到的。但是,您可以通过 Storyboard制作自己的自定义类,如下所示:

Custom Login View Controller from a Navigation Controller

代码将看起来像这样用于解析:

导入 UIKit 导入解析

类 CustomLoginViewController: UIViewController {

@IBOutlet weak var usernameField: UITextField!
@IBOutlet weak var passwordField: UITextField!

var actInd : UIActivityIndicatorView = UIActivityIndicatorView(frame: CGRectMake(0,0, 150, 150)) as UIActivityIndicatorView

override func viewDidLoad() {
    super.viewDidLoad()

    self.actInd.center = self.view.center
    self.actInd.hidesWhenStopped = true
    self.actInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
    view.addSubview(self.actInd)

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    // Get the new view controller using segue.destinationViewController.
    // Pass the selected object to the new view controller.
}
*/

// MARK: Actions

@IBAction func loginAction(sender: AnyObject) {

    var username = self.usernameField.text
    var password = self.passwordField.text

    if (username.utf16Count < 4 || password.utf16Count < 5) {

        var alert = UIAlertView(title: "Invalid", message: "Username must be greater then 4 and Password must be greater then 5", delegate: self, cancelButtonTitle: "OK")
        alert.show()

    }else {

        self.actInd.startAnimating()

        PFUser.logInWithUsernameInBackground(username, password: password, block: { (user, error) -> Void in

            self.actInd.stopAnimating()

            if ((user) != nil) {

                var alert = UIAlertView(title: "Success", message: "Logged In", delegate: self, cancelButtonTitle: "OK")
                alert.show()

            }else {

                var alert = UIAlertView(title: "Error", message: "\(error)", delegate: self, cancelButtonTitle: "OK")
                alert.show()

            }

        })

    }

}

@IBAction func signUpAction(sender: AnyObject) {

    self.performSegueWithIdentifier("signUp", sender: self)

}

关于ios - 使用 Storyboard自定义 Parse PFLoginViewController 的布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34675440/

相关文章:

ios - 应用重启时照片丢失并取消固定

ios - 从核心数据删除后重新加载表格 View

ios - 使用 Metal 的旧设备上的内存使用量不断上升

objective-c - "Mutating method sent to immutable object"尽管对象是 NSMutableDictionary

ios - executefetchrequest 导致崩溃

objective-c - 为什么我收到 'Expression Result Unused' 警告?

ios - 错误域 = PlugInKit 代码 = 13 "query cancelled"UserInfo = {NSLocalizedDescription = 查询已取消}

iphone - View 内的 View (iOS、绘图属性)

ios - 解析检索错误的 PFFile

ios - 如何将 Parse 的 PFObject 改造为现有的复杂聚合模型类?