开发者

textview not responding to delegates iphone

In my application, I'm forcefully showing/hiding keyboard by making textview becomefirstresponder and resignfirstresponder and also setting textview editable YES and NO respectively.

But after hiding keyboard if I tap on textview, the keyboard doesn't show up. I'm setting textview delegate to self. And the delegate method is firing up the first time but not after that.

EDIT: I'm using the following code which I am writing for a custom button-tap and checking flags to check keyboard is in hidden state or otherwise:

switch(rotationFlag)
{
    case 0:
    {
        [self hideKeyboard];
        rotationFlag = 开发者_开发技巧1;
        break;
    }

    case 1:
    {
        [self showKeyboard];
        rotationFlag = 0;
        break;
    }
}

-(void)hideKeyboard{
[txtVwForPosts setEditable:FALSE];
[txtVwForPosts resignFirstResponder];   
 }

 -(void)showKeyboard{
[txtVwForPosts setEditable:TRUE];
[txtVwForPosts becomeFirstResponder];   
 }

What is it that I'm doing wrong?

Can anybody please help? Thanx in advance.


I'm not sure whats wrong with your code but following is a code which i wrote for same purpose:

-(IBAction)hideShowKeyboard:(id)sender
{
    if([tv isFirstResponder])
    {
        [tv resignFirstResponder];
    }
    else
    {
        [tv becomeFirstResponder];
    }
}

THis was the action for the button. and tv is the TextView outlet. But this view doesn't detect tap on the textview after the keyboard is hidden. If you want to detect taps just avoid setting the editable property to NO.


switch(rotationFlag)
{
    case 0:
    {
        [self hideKeyboard];
        rotationFlag = 1;
        break;
    }

    case 1:
    {
        [self showKeyboard];
        rotationFlag = 0;
        break;
    }
}

-(void)hideKeyboard
{
  [txtVwForPosts resignFirstResponder];   
 }

 -(void)showKeyboard
{
  [txtVwForPosts becomeFirstResponder];   
 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜