Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UIView单击显示和隐藏问题_Iphone_Ios_Ipad_Uiview - Fatal编程技术网

Iphone UIView单击显示和隐藏问题

Iphone UIView单击显示和隐藏问题,iphone,ios,ipad,uiview,Iphone,Ios,Ipad,Uiview,下面的代码是我用来在单击时显示视图的,当我再次单击时,它可以正常工作,但是当我一次又一次单击时,视图不再隐藏,只是停留在视图中 - (IBAction)didTapFlag:(id)sender { checkBtnCondition=YES; menuView.hidden=YES; if([audioPlayer isPlaying]) { [self playPauseAudio]; } if( iscommentOn==NO) { [mCommentView hide];

下面的代码是我用来在单击时显示视图的,当我再次单击时,它可以正常工作,但是当我一次又一次单击时,视图不再隐藏,只是停留在视图中

- (IBAction)didTapFlag:(id)sender
{
checkBtnCondition=YES;
menuView.hidden=YES;
if([audioPlayer isPlaying])
{
    [self playPauseAudio];
}
if( iscommentOn==NO)
{
    [mCommentView hide];
    iscommentOn=YES;
}
else
{
     iscommentOn=NO;
        if(iscommentOn)
        if(![commentPlayer1 isPlaying])
          {
            iscommentOn=NO;
          }
        if(!iscommentOn)
          {
            iscommentOn=YES;
           if(mCommentView)
             {
                [commentPlayer1 stop];
                 commentPlayer1 = nil;
                [mCommentView hide];
                return;
            }
            float comx;
            float comy;
            if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
            {
                comx = 200;
                comy = 280;
            }
            else
            {
                comx = 50;
                comy = 170;
            }
            mCommentView = [[CommentUtility alloc] initWithFrame:CGRectMake(comx, comy, 330, 250)];
            [mCommentView setDelegate:(id)self];
            [self.view addSubview:mCommentView];
            [mCommentView show];
         }
      }
   }

如果我的代码有任何问题,我应该在代码中进行什么更改。请帮助我。

示例代码:

- (IBAction)didTapFlag:(id)sender
{
    int btnTag = ((UIButton *)sender).tag;
    if (btnTag == 0)
    {
        [yourView setHidden:YES];
        yourButton.tag = 1;
    }
    else
    {
        [yourView setHidden:NO];
        yourButton.tag = 0;
    }
}

你的问题解决了吗?是的,我解决了问题