Home > DeveloperSection > Forums > UIView show and hide on click issue
Ankit Singh

Total Post:341

Points:2389
Posted on    June-04-2013 2:18 AM

 iPhone iPhone 
Ratings:


 1 Reply(s)
 1145  View(s)
Rate this:
Hi,

The following code which i used to show the view on click and hide when i clicks again,It works fine, But when Click again and again the view not hide any more and simply stays in the view.

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

What Change should I want to in my code, Any thing wrong with my code.
Please help me out.


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    June-05-2013 8:39 AM

Hi Ankit,

Try as following

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

I hope it helpful for you.

Don't want to miss updates? Please click the below button!

Follow MindStick