What's a simple way to get a text input popup dialog box on an iPhone

后端 未结 12 2092
-上瘾入骨i
-上瘾入骨i 2020-12-02 03:42

I want to get the user name. A simple text input dialog box. Any simple way to do this?

12条回答
  •  猫巷女王i
    2020-12-02 04:30

    Tested out Warkst's third code snippet--worked great, except I changed it to be default input type instead of numeric:

    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Hello!" message:@"Please enter your name:" delegate:self cancelButtonTitle:@"Continue" otherButtonTitles:nil];
    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    UITextField * alertTextField = [alert textFieldAtIndex:0];
    alertTextField.keyboardType = UIKeyboardTypeDefault;
    alertTextField.placeholder = @"Enter your name";
    [alert show];
    

提交回复
热议问题