2013-06-01 156 views
-2

下面的代碼,我用來顯示點擊和隱藏,當我再次點擊時的視圖,它工作正常,但是當再次點擊視圖不隱藏任何更多,只是停留在視圖。UIView顯示和隱藏點擊問題

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

我應該在我的代碼中想要什麼改變,任何與我的代碼有關的錯誤,請幫助我。

+0

你有沒有解決您的問題? – Bhavin

+0

是的,我解決了這個問題 –

回答

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