Xcode TextField的Alertview适用于ios7,但不适用于ios6.1

Xcode TextField的Alertview适用于ios7,但不适用于ios6.1,xcode,Xcode,这是我的代码,它在ios7中工作得很好,但在ios6中却不行。要在ios 6.1上使用它,我应该做哪些更改在ios 7中无法轻松更改UIAlertView的视图层次结构。(您也不应该这样做;文档明确告诉您不要这样做。)前往开发人员论坛,查看关于它的长时间讨论 在您的情况下,另一种选择是设置alert.alertViewStyle=UIAlertViewStylePlainTextInput这将为您添加一个文本字段。您可以使用UITextField*textField=[alertView tex

这是我的代码,它在ios7中工作得很好,但在ios6中却不行。要在ios 6.1上使用它,我应该做哪些更改在ios 7中无法轻松更改UIAlertView的视图层次结构。(您也不应该这样做;文档明确告诉您不要这样做。)前往开发人员论坛,查看关于它的长时间讨论

在您的情况下,另一种选择是设置alert.alertViewStyle=UIAlertViewStylePlainTextInput这将为您添加一个文本字段。您可以使用UITextField*textField=[alertView textfieldatinex:0]在UIAlertView委托回调中访问它

例如:

    if ([district.text isEqualToString:@""])
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Please fill the fields" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }
    else if([myTextField.text isEqualToString:@""])
    {

        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Please fill the fields" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }
    else if ([catname.text isEqualToString:@""])
    {

        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Please fill the fields" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }
    else if([msg.text isEqualToString:@""])
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Please fill the fields" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];

    }
UIAlertView *alertView = [[UIAlertView alloc]
                              initWithTitle:@"Alert"
                              message:@"enter your details:"
                              delegate:self
                              cancelButtonTitle:@"Cancel"
                              otherButtonTitles:@"Ok", nil];
    [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
    /* Display a numerical keypad for this text field */
    UITextField *textField = [alertView textFieldAtIndex:0];
    textField.keyboardType = UIKeyboardTypeNumberPad;

[alertView show];