我想做一个简单的alertView并询问电话号码......
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"What is your phone number?"
message:nil
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Continue", nil];
message.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField* answerField = [message textFieldAtIndex:0];
answerField.keyboardType = UIKeyboardTypeNumberPad;
answerField.placeholder = @"+43 ...";
[message show];
我需要用什么来检查一下这个号码(比如Mysql等)
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
UITextField *textField = [alertView textFieldAtIndex:0];
?????????
// Something like if (textField == "090012345678") -> NSLog(@"WOW"); ...
}
答案 0 :(得分:4)
如果您不知道如何比较两个字符串是否相同,那么我建议您在Objective-C上找一些基本的教程。
if ([textField.text isEqualToString:@"090012345678"]) {
NSLog(@"WOW");
}