监听AlertViewController的文本输入框的内容

[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;

}

 

posted @ 2016-04-06 10:04  aRenOuBa  阅读(218)  评论(0编辑  收藏  举报