【问题标题】:UIAlertView handle textfieldUIAlertView 处理文本字段
【发布时间】:2013-09-07 19:21:04
【问题描述】:

我想做一个简单的 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"); ...

   }

【问题讨论】:

    标签: ios objective-c alertview


    【解决方案1】:

    如果您不知道如何比较两个字符串是否相同,那么我建议您寻找一些有关 Objective-C 的基本教程。

    if ([textField.text isEqualToString:@"090012345678"]) {
        NSLog(@"WOW");
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-26
      • 2013-09-24
      • 1970-01-01
      相关资源
      最近更新 更多