2012-03-20 46 views
2

我在我的视图中有两个文本字段。我使用IB做了它。在第二个文本字段中我使用的操作工作表如何使其他文本字段的键盘在访问其他文本字段时消失

在textField1中输入文本后我在文本字段2-2中。第二个文本字段中我使用操作表与选择器来选择日期。所以我在打开操作表之前辞职了textfield -2键盘。当我试图辞职键盘时,我解雇了行动表后并没有回来。 我用

- (BOOL)textFieldShouldReturn:(UITextField *)textField{ 
    [textfield1 resignFirstResponder]; 
    return YES; 
} 

辞职textfield1的..

回答

4
- (void) viewDidLoad 
{ 
    //don't forget to add <UITextFieldDelegate> in your .h 
    firstTextField.delegate=self; 
    secondTextField.delegate=self; 
} 

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField 
{ 
    if(textField.tag==2) 
    { 
     //Here you can call function to view your datepicker 
     return NO; //Will not open keyboard for second textfield. 
    } 
    return YES; 
} 

- (BOOL)textFieldShouldReturn:(UITextField *)textField 
{ 
    [textField resignFirstResponder]; 
    return YES; 
} 
0

你必须返回当前文本框textFieldShouldReturn方法改变你的textFieldShouldReturn梅托德像下面

- (BOOL)textFieldShouldReturn:(UITextField *)textField{ 
    [textField resignFirstResponder]; 
    return YES; 
} 
0

设置标签的每一个文本字段,并检查它们在

-(BOOL)textFieldShouldReturn:(UITextField *)textField 
{ 
    if([textfield.tag == 1]) 
    { 
     [textFieldFirst resignFirstResponder]; 
    } 
    else 
    { 
    // your action sheet code here 
    } 
    return YES; 
} 
0

您需要提供返回的第一个标签的文本字段,

在这个方法中,

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField 
{    
    if (textField.tag == 2) 
    { 
     [textField1 resignFirstResponder]; 
     // your action sheet code here 
    } 
} 

- (BOOL)textFieldShouldReturn:(UITextField *)textField   
{ 
    [textfield resignFirstResponder] 
    return YES; 
} 
+0

我试图为u说,但它简化版,工作........... – vamsi575kg 2012-03-20 11:22:27

+0

有出文本字段键盘我传递到第二个。第二字段的文本字段没有打开,因为我辞去了第一响应者..但是第一字段的键盘没有退出@ – vamsi575kg 2012-03-20 11:25:51

相关问题