---
title: "UIView show and hide on click issue"  
description: "UIView show and hide on click issue"  
author: "Anonymous User"  
published: 2013-06-04  
updated: 2013-06-05  
canonical: https://www.mindstick.com/forum/985/uiview-show-and-hide-on-click-issue  
category: "iphone"  
tags: ["iphone"]  
reading_time: 1 minute  

---

# UIView show and hide on click issue

Hi,\
The following [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) which i used to show the [view](https://yourviews.mindstick.com/view/84701/layoffs-in-google-india-2023-view) on [click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) and hide when i clicks again,It [works fine](https://answers.mindstick.com/qa/115732/my-software-works-fine-on-windows-10-but-crashes-on-windows-11-why), But when Click again and again the view not hide any more and simply stays in the view.\
**- (IBAction)didTapFlag:(id)sender****{****checkBtnCondition=[YES](https://www.mindstick.com/forum/157763/how-to-return-yes-no-based-on-date-comparison-in-sql);****menuView.hidden=YES;****if([audioPlayer isPlaying])****{** **[[self](https://www.mindstick.com/articles/44535/smart-ways-to-secure-self-storage-facilities) 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](https://www.mindstick.com/interview/1718/describe-float-containment) 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](https://answers.mindstick.com/qa/48468/who-wrote-the-the-wrong-enemy-america-in-afghanistan-2001-2014-and-when) with my code.Please help me out.

## Replies

### Reply by AVADHESH PATEL

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.


---

Original Source: https://www.mindstick.com/forum/985/uiview-show-and-hide-on-click-issue

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
