Unable to add UITextField to UIAlertView on iOS7…works in iOS 6

后端 未结 7 1455
梦毁少年i
梦毁少年i 2020-12-01 01:34

The code below works on iOS6 (and before) but the UITextField does not display in iOS7...any ideas on how to get a UITextField to display in an UIAlterView in iOS7?

7条回答
  •  -上瘾入骨i
    2020-12-01 01:53

    UIAlertView *alertView = [[UIAlertView alloc]
                                      initWithTitle:@"Credit Card Number"
                                      message:@"Please enter your credit card number:"
                                      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];
    

提交回复
热议问题