2012-03-01 27 views
0

我需要彈出日期選擇器在我的應用程序中,當我點擊文本字段時,我做得很好,但問題是在選擇日期之後日期選擇器將遠離屏幕,當我點擊文本字段它回來我知道它簡單但我需要幫助提前感謝。iphone應用程序中的日期選擇器

+0

正是你想要的日期選擇器什麼 – Purva 2012-03-01 07:19:46

+0

首先我想從日期選擇器的日期和做後,日期選擇器會automaticallay消失 – 2012-03-01 07:22:48

+0

把工具欄正上方的日期選取器和在工具欄的那個barbutton上添加[picker setHidden:YES]並在你顯示Picker時顯示工具欄。 – Purva 2012-03-01 07:29:41

回答

0

試試這個:

BOOL availability ; 
    availability = NO; 

放於方法,其中調用方法來顯示的DatePicker

if(availability) 
{ 
    picker.hidden =YES; 
    availability=NO; 
} 
else 
{ 
    picker.hidden =NO; 
    availability=YES; 
} 
1

試試這個: - 這是的UITextField delgete

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField 
{ 

picker.hidden =YES; // if You want 

} 

-(BOOL) textFieldShouldReturn:(UITextField *)textField{ 

     [textField resignFirstResponder]; 

picker.hidden =NO;// if You want 

} 
1

嘗試

yourTextField.inputView = yourPicker; 
yourPicker.delegate = self; //(you need to declare your class will implement <UIPickerViewDelegate> 

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{ 
    //change your yourTextField.text here 
相關問題