2014-09-05 38 views
0

我是新来解析。我正在使用ios SDK进行应用程序尝试实现登录和注册。我下载了最新版本(1.2.21)。我正在使用PFSignUpViewController来实现注册。我尝试了继承控制器来定制它,但我看到了一些问题。首先,我似乎无法更改字段占位符名称的用户名或密码。密码字段甚至不显示占位符;它是空的。其次,我无法打开附加领域。尽管有定制代码,没有额外的字段显示。有谁知道什么可能导致这种情况?或者它可能是分析框架中的错误? - 下面是我的PFSignUpViewController的子类。解析ios sdk默认注册不起作用

#import "QSignUpViewController.h" 

@interface QSignUpViewController() 

@end 

@implementation QSignUpViewController 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 

    self.fields = PFSignUpFieldsUsernameAndPassword | 
    PFSignUpFieldsSignUpButton | PFSignUpFieldsAdditional; 

    self.signUpView.usernameField.placeholder = @"Email"; 
    self.signUpView.passwordField.placeholder = @"Password"; 
    [self.signUpView.additionalField setPlaceholder:@"Phone Number"]; 

    [self setEmailAsUsername: YES]; 
    //self.signUpView.emailAsUsername = YES; 


} 

回答

0

更新 - 问题应该在最新的被纠正的iOS SDK 1.3

有与当前SDK继承了PFSignUpViewController(1.2.21版本)的错误,你可以通过恢复解决问题回到sdk parse.com/downloads/ios/parse-library/1.2.19的版本1.2.19 - 至少在1.2.22发布之前。

至于占位符文本问题 - PFSignUpView中的UITextFields正在使用属性占位符属性。例如,下面的代码片段将把usernameField的地方设置为“Email”。

PFSignUpView *signUpView = [self signUpView]; 
[[signUpView usernameField] setAttributedPlaceholder:nil]; 
[[signUpView usernameField] setPlaceholder:@"Email"]; 
0

导入 “ViewController.h”

导入 “解析/ parse.h中”

@interface的ViewController()

@property(弱,非原子)IBOutlet中的UILabel * myLabel;

@end

@implementation的ViewController

  • (无效)viewDidLoad中{

    [超级viewDidLoad中];

    //在加载视图后,通常从笔尖执行任何其他设置。

    [self mySignUp];

}

  • (无效)mySignUp {

    PFUser *用户= [PFUser用户];

    user.username = @“name”;

    user.password = @“1”;

    用户。电子邮件= @“电子邮件地址”;

    [用户signUpInBackgroundWithBlock:^(BOOL成功,NSError *错误){

    if(!error) { 
    
        NSLog(@"Successfully signed up"); 
    
        _myLabel.text = [NSString stringWithFormat:@"Welcome %@!", user.username]; 
    } 
    
    else { 
    
        NSLog(@"Successfully signed up"); 
        _myLabel.text = @"You are not logged in"; 
    
        NSLog(@" %@", [error userInfo][@"error"]); 
    
    
    } 
    

    }];

}

  • (无效)didReceiveMemoryWarning { [超级didReceiveMemoryWarning]; //处置任何可以重新创建的资源。 }

@end