2014-09-05 44 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