所以後端正在工作,我可以成功創建帳戶和登錄。現在我想讓他們轉換到主屏幕,所以我如何設置,以便如果sigup /登錄成功轉換?這是我的代碼:如何在註冊和登錄後切換視圖?
- (IBAction)signUp:(UIButton *)sender {
NSString *name = _textUsername.text;
NSString *password = _textPassword.text;
NSString *email = [_textEmail.text lowercaseString];
//---------------------------------------------------------------------------------------------------------------------------------------------
if ([name length] == 0) { [ProgressHUD showError:@"Name must be set."]; return; }
if ([password length] == 0) { [ProgressHUD showError:@"Password must be set."]; return; }
if ([email length] == 0) { [ProgressHUD showError:@"Email must be set."]; return; }
//---------------------------------------------------------------------------------------------------------------------------------------------
[ProgressHUD show:@"Please wait..." Interaction:NO];
PFUser *user = [PFUser user];
user.username = name;
user.password = password;
user.email = email;
user[PF_USER_EMAILCOPY] = email;
user[PF_USER_FULLNAME] = name;
user[PF_USER_FULLNAME_LOWER] = [name lowercaseString];
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error)
{
if (error == nil)
{
ParsePushUserAssign();
[ProgressHUD showSuccess:@"Succeed."];
[self dismissViewControllerAnimated:YES completion:nil];
}
else [ProgressHUD showError:error.userInfo[@"error"]];
}];
還有什麼想法爲什麼我的文本字段不會自動進入下一個?很確定代碼是正確的。謝謝。
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if (textField == _textUsername)
{
[textField resignFirstResponder];
[_textEmail becomeFirstResponder];
}
else if (textField == _textEmail)
{
[textField resignFirstResponder];
[_textPassword becomeFirstResponder];
}
else if (textField == _textPassword)
{
[textField becomeFirstResponder];
[_textBirthday becomeFirstResponder];
}
else if (textField == _textBirthday)
{
[self actionRegister];
}
return YES;
如何使用僅包含dismissViewController的單線程替換註冊:方法。你可能會解開這個問題。 – danh
@danh視圖控制器已被解僱,我想在成功註冊/登錄後轉換到另一個。 – George
我明白了。在這種情況下,請發佈檢測到沒有用戶的情況並提交註冊/登錄的代碼。 (並刪除發佈的代碼,除了解僱之外沒有任何其他的代碼)。 – danh