Adding TextField to UIAlertView

前端 未结 9 1376
不知归路
不知归路 2021-02-12 12:38

I need to add a TextField to an UIAlertView. I understand that apple discourage this approach. So is there any library that i could make use of to add

9条回答
  •  情歌与酒
    2021-02-12 12:56

    Try something like this:

    UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Title"
                                                     message:@"\n\n"
                                                    delegate:self
                                           cancelButtonTitle:@"Cancel"
                                           otherButtonTitles:@"Save", nil] autorelease];
    CGRect rect = {12, 60, 260, 25};
    UITextField *dirField = [[[UITextField alloc] initWithFrame:rect] autorelease];
    dirField.backgroundColor = [UIColor whiteColor];
    [dirField becomeFirstResponder];
    [alert addSubview:dirField];
    
    [alert show];
    

提交回复
热议问题