2015-05-22 36 views

回答

0

我的猜測是:

使用UITextFieldDelegate來檢查當用戶已經結束了電子郵件UITextField的編輯。獲取電子郵件地址並將其發送到您的服務器以檢查其是否可用。然後根據服務器的響應顯示錯誤。

0

你在找什麼叫做驗證, 試試這個US2FormValidator

這看起來與你的相似。

另外,Git上有很多iOS驗證器可用。

0

首先刪除你的userIDTextField。並實施以下代理方法 -

- (void)textFieldDidEndEditing:(UITextField *)textField 
{ 
    // Start showing UIActivityIndicator 
    // implement block base web service call to check your user id availability. I will recommended NSURLConnection wrapper base block - http://stackoverflow.com/questions/14914480/nsurlconnection-with-blocks 


// on results stop activity and show your desire image icon 

} 
0

將此代碼輸入到viewDidLoad中。當你的textField被改變時(甚至向後按鍵),這段代碼調用checkEmailMethod。

- (void)viewDidLoad{ 
    .... 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkEmailMethod) name:UITextFieldTextDidChangeNotification object:nil]; 
} 

然後定義下面的checkEmailMethod;

- (void)checkEmailMethod{ 
    //---Send your textField's text to the server 
}