Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show/hide view in Xcode [closed]

Good day..! I would like to ask some assistance no how to accomplish this task in xcode?

here's the scenario.. I have several buttons.. example below..

enter image description here

--> Sample
--> Sample
--> Sample

When you clicked on the first sample1, it will display a text containing information.. when you clicked again sample1, it will return to its original position..

Example when clicked

--> Sample1
    --> Information here

--> Sample2
--> Sample3

when clicked again

--> Sample1
--> Sample2
--> Sample3

Hope to hear from you soon..

Thanks,

Link

like image 883
Link Avatar asked Nov 27 '22 14:11

Link


2 Answers

You can set the hidden property as mayuur and iDhaval suggested

view.hidden = YES; // or
view.hidden = NO;

or by calling setHidden:

[view setHidden:YES]; // or
[view setHidden:NO];

You could also set the alpha property of the view to 0.0f, but know that it still receives touch events.

view.alpha = 0.0f; // or
[view setAlpha:0.0f];

See ColdLogic's answer to UIView hidden property...is there more to it? for code to animate the view "fading out," and Torsten Walter's answer to what's the difference between view's hidden = yes and alpha = 0.0f for more information on the difference between setting the alpha property of a view to 0.0f and setting its hidden property to YES, and how iOS handles it in different contexts. The relevant Apple documentation on UIView could prove helpful, too.

  • developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html#//apple_ref/doc/uid/TP40006816-CH3-SW134

In case you want to animate the showing and hiding of those informational text views by moving them, it wouldn't be much of a stretch to modify the code at iDev Recipes for implementing side swiping on a table as in the Twitter app. The full source code is available on GitHub.

  • idevrecipes.com/2011/04/14/how-does-the-twitter-iphone-app-implement-side-swiping-on-a-table/
  • github.com/boctor/idev-recipes/tree/master/SideSwipeTableView

For more complex animation, reference Apple's Core Animation Programming Guide.

  • developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.html

Since I'm new to the site and it's limiting the number of hyperlinks I can include, you'll have to copy and paste the URLs next to the bullets.

like image 74
yurrriq Avatar answered Dec 05 '22 13:12

yurrriq


Please use the hidden property with respective view on click event of button.

like image 24
iDhaval Avatar answered Dec 05 '22 15:12

iDhaval