UITextFiled鍵盤彈出前做ASI請求並且彈出自定view


.H裏面定義的@property(nonatomic,strong)UITextField *publicFiled;

    @property(nonatomic,strong)UIView *typePickerView;





.M文件裏

#pragma mark - UITextFieldDelegate


- (void)textFieldDidBeginEditing:(UITextField *)textField{

             self.publicFiled=textField;

            self.publicFiled.inputView=self.typePickerView;

}


-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
    if (self.outPatientList.count==0&&!self.typePickerView) {
        self.publicFiled=textField;
        [self listDataSource:[NSNumber numberWithInt:TAG_FOURTY_NINE] ];//自定義了一個方法用不請求網絡數據的
        return NO;

    }
    return YES;
}



//異步請求委託
- (void)requestFinished:(ASIHTTPRequest *)request

 switch (request.tag) {
            case TAG_FOURTY_NINE:

            {

                     self.outPatientList=[rotdic objectForKeyedSubscript:@"recordList"];
                    self.typePickerView=(UIView *)([[NSBundle mainBundle]loadNibNamed:@"OutPatientType" owner:self options:nil][0]);//此處的@"OutPatientType"是我定義好的一個view.xib


                     UIPickerView *typePKV=(UIPickerView *)[self.typePickerView viewWithTag:1];
                     typePKV.delegate=self;
                     [self.publicFiled becomeFirstResponder];

              }

              break;

          

              default:

                break;
        }
        
        
        
}

發佈了35 篇原創文章 · 獲贊 0 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章