How to dismiss an UIAlertController and the keyboard simultaneously?

后端 未结 8 1239
离开以前
离开以前 2021-02-05 13:04

I have created a signup form with a UIAlertController and used the method addTextFieldWithConfigurationHandler to add a text field. But there is a litt

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-05 13:30

    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    
       { 
    
    if (buttonIndex==1) {
    
            [[alertView textFieldAtIndex:0] resignFirstResponder];
    
            } else {
    
                [[alertView textFieldAtIndex:0] resignFirstResponder];
    
            }
        }
    

    Use your button index (Ok or Cancel button index)

提交回复
热议问题