2017-06-19 9 views

答えて

0

これが私の答えをチェックアウトするサンプルコード

- (BOOL) textFieldShouldReturn:(UITextField *) textField { 
    if (textField == textField1) { 
     [textField2 becomeFirstResponder]; 
    } else if (textField == textField2) { 
     [textField3 becomeFirstResponder]; 
    } else if (textField == textField3) { 
     [textField resignFirstResponder]; 
     [self callAPI]; //Call API Assuming it the last field 
    } 
    return YES; 
} 

スウィフトバージョン

func textFieldShouldReturn(_ textField: UITextField) -> Bool { 
    if textField == textField1 { 
     textField2.becomeFirstResponder() 
    } else if textField == textField2 { 
     textField3.becomeFirstResponder() 
    } else if textField == textField3 { 
     textField.resignFirstResponder() 
     self.callAPI() 
    } 
    return true 
} 
0

使用self.view.endEditing =真

関連する問題