[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { //这里需要添加观察者 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(search:) name:UITextFieldTextDidChangeNotification object:textField]; }];
//实现观察方法 - (void)search:(NSNotification *)noti { UITextField *textfield = noti.object; self.alertText = textfield.text; }