1

I'm trying to create a drop down menu but I still dont know how to do.

So I think I can set a tableview hidden by default and when people tap a button the tableview will appear. I know how to hide/unhide a object but I dont know how to set a object hidden by default. Could you guys help me fix it?

Thank in advance.

jackiviet
  • 131
  • 1
  • 10

1 Answers1

1

In the storyboard file, you can set the "Hidden" property on the view. This property is under the "View" section of the Attributes Inspector tab.

Or in the "-(void)viewWillAppear:(BOOL)animated" function of your class, set [table setHidden:true];

One of those should work.

Niro
  • 776
  • 8
  • 15
  • Thank you. I think if I load some objects to the main view and set it hidden, it will cause my app run slowly. Could you give me some advice :D ? – jackiviet Feb 27 '13 at 12:12
  • Give me a better overview of your project. From what I understand, you have a main view with a button that, when they press the button, shows a drop down menu (UITableVew), am I correct? Here is a decent tutorial by the way for a real simple drop down: http://iphonebymilindjoshi.blogspot.com/2011/06/how-to-set-drop-down-menu-in-iphone.html – Niro Feb 27 '13 at 18:25
  • In the tutorial, he sets his tableview to hidden in his viewDidLoad function, which is fine so long as you hide the tableview again before you leave the main view. By hiding the tableview in the viewWillAppear function, the tableview will be hidden each time you are about to show this view. With proper memory management (retaining and releasing objects you do/don't need), speed should not be an issue here – Niro Feb 27 '13 at 18:29
  • Actualy I want to create buttons like "Facebook notification buttons". When people click it, a small view will appear. Sure I will read your tutorials. Thank you very much. – jackiviet Feb 28 '13 at 10:12
  • I cant run the source code because "Missing the SDK target iphone4" but I understand the code. For my project these tableviews will load (appear) in every view controller so how can I create these tableviews programmatically. I don't want to create it by hand (drag and drop in storyboard file). Thank you in advance :D – jackiviet Feb 28 '13 at 16:44
  • There are a number of great tutorials/asmple code for creating a table programmatically, even here on stack overflow. Check some of these out and see if they can help you: – Niro Mar 01 '13 at 15:32
  • http://stackoverflow.com/questions/10003034/creating-a-tableview-programmatically-with-objective-c-ios http://stackoverflow.com/questions/11537069/create-navigation-bar-for-tableview-programmatically-in-objective-c http://stackoverflow.com/questions/8066144/ipad-how-to-create-programmatically-multiple-tables-on-one-view – Niro Mar 01 '13 at 15:32