解析自定义PFSignUpViewController无响应

时间:2015-04-01 20:22:02

标签: ios parse-platform

我将PFSignUpViewController子类化为使我的应用看起来有点不同。我看起来像这样:

enter image description here

初始化的代码是:

if (![PFUser currentUser]) { // No user logged in
        // Create the log in view controller
        CustomSignUp *logInViewController = [[CustomSignUp alloc] init];
        [logInViewController setDelegate:self]; // Set ourselves as the delegate

        // Create the sign up view controller
        self.signUpViewController = [[TheActualSignUp alloc] init];
        [self.signUpViewController setDelegate:self]; // Set ourselves as the delegate
        self.signUpViewController.fields = (PFSignUpFieldsUsernameAndPassword
                                   | PFSignUpFieldsSignUpButton
                                   | PFSignUpFieldsEmail
                                   | PFSignUpFieldsAdditional
                                   | PFSignUpFieldsDismissButton);
        [self.signUpViewController.signUpView.additionalField setPlaceholder:@"First & Last Name"];
            /*    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button addTarget:self
                   action:@selector(choosephoto)
         forControlEvents:UIControlEventTouchUpInside];
        [button setImage:[UIImage imageNamed:@"Camera.png"] forState:UIControlStateNormal];
        button.frame = CGRectMake(160, 320, 50, 50);
        [signUpViewController.view addSubview:button];*/
        // Assign our sign up controller to be displayed from the login controller
        [logInViewController setSignUpController:self.signUpViewController];
        logInViewController.facebookPermissions = @[ @"email", @"public_profile", @"user_friends" ];
        logInViewController.fields = (PFLogInFieldsUsernameAndPassword
                                  | PFLogInFieldsFacebook
                                  | PFLogInFieldsTwitter
                                  | PFLogInFieldsLogInButton
                                  | PFLogInFieldsSignUpButton
                                  | PFLogInFieldsPasswordForgotten);

        // Present the log in view controller

        [self presentViewController:logInViewController animated:YES completion:NULL];
    }

但是,单击“注册”或“取消按钮”不执行任何操作。我把它工作得很好,直到我将Parse框架更新为1.7。现在,注册中的任何内容都无法正常工作。我的子视图代码如下:

#import "TheActualSignUp.h"


@implementation TheActualSignUp

-(void)viewDidLoad {
    self.view.backgroundColor = [UIColor blackColor];


            UIImageView *logoView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"AppIcon76x76@2x.png" ]];

            self.signUpView.logo = logoView; // logo can be any UIView

            self.fieldsBackground = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SignUpFieldBG.png"]];

            UITextView *iprayed = [[UITextView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.width - 235, self.view.bounds.size.width, 40)];

            iprayed.text = @"iPrayed 4 U Sign Up";

            iprayed.textAlignment = NSTextAlignmentCenter;

            iprayed.textColor = [UIColor whiteColor];

            iprayed.backgroundColor = [UIColor blackColor];

            UIFont *cellFont = [UIFont fontWithName:@"Verdana-Bold" size:25];

            iprayed.font = cellFont;


            [self.signUpView addSubview:iprayed];

        //    [self.signUpView insertSubview:self.fieldsBackground atIndex:1];




}
- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

        CALayer * l = [self.signUpView.logo layer];
        [l setMasksToBounds:YES];
        [l setCornerRadius:(self.view.bounds.size.width - 250)/2];
        [l setBorderWidth:2.0];
        [l setBorderColor:[[UIColor whiteColor] CGColor]];

        // Set frame for elements
        [self.signUpView.dismissButton setFrame:CGRectMake(10.0f, 10.0f, 87.5f, 45.5f)];
        [self.signUpView.logo setFrame:CGRectMake(125, 15, self.view.bounds.size.width - 250, self.view.bounds.size.width - 250)];

        [self.signUpView.signUpButton setFrame:CGRectMake(35.0f, self.view.bounds.size.width + 50, self.view.bounds.size.width - 70, 40.0f)];
        [self.signUpView.usernameField setFrame:CGRectMake(35.0f, self.view.bounds.size.width - 132, self.view.bounds.size.width - 70, 50.0f)];
        [self.signUpView.passwordField setFrame:CGRectMake(35.0f, self.view.bounds.size.width - 90, self.view.bounds.size.width - 70, 50.0f)];
        [self.signUpView.emailField setFrame:CGRectMake(35.0f, self.view.bounds.size.width - 48, self.view.bounds.size.width - 70, 50.0f)];
        [self.signUpView.additionalField setFrame:CGRectMake(35.0f, self.view.bounds.size.width - 6, self.view.bounds.size.width - 70, 50.0f)];
        [self.fieldsBackground setFrame:CGRectMake(35.0f, self.view.bounds.size.width - 135, self.view.bounds.size.width - 70, 174.0f)];


}

@end

1 个答案:

答案 0 :(得分:0)

如果你在viewDidLayoutSubviews中这样做,那么你将是一个无限循环,因为这些方法会改变UI并再次调用viewDidLayoutSubviews