简体   繁体   English

TextView没有回应代表iPhone

[英]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. 在我的应用程序中,我通过使textview成为firstresponder和resignfirstresponder并设置textview可编辑为YES和NO来强制显示/隐藏键盘。

But after hiding keyboard if I tap on textview, the keyboard doesn't show up. 但是在隐藏键盘后,如果我单击textview,则键盘不会显示。 I'm setting textview delegate to self. 我将textview委托设置为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. 提前感谢。

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

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

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

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

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. 电视是TextView插座。 But this view doesn't detect tap on the textview after the keyboard is hidden. 但是隐藏键盘后,该视图不会检测到textview上的点击。 If you want to detect taps just avoid setting the editable property to NO. 如果要检测点击,请避免将editable属性设置为NO。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM