-2

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

- (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];
         }
      }
   }

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

4

1 回答 1

1

示例代码:

- (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;
    }
}
于 2013-06-01T06:44:52.917 回答