title: Create drop down menu with UITableView
body: <p>I am trying to build a drop down menu.  When I click a button button I want a table view to open and then tap on the <code>UITableViewCell</code>.  I want the cell data to display in the button</p>
  
  <p>.h file </p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import &lt;QuartzCore/QuartzCore.h&gt;
  @interface ViewController : UIViewController &lt;UITableViewDelegate,   UITableViewDataSource&gt;{
      IBOutlet UITableView *tblSimpleTable;
      IBOutlet UIButton *btn;
      IBOutlet UIImageView *i;
      BOOL flag;
      NSArray *arryData;
  }
  @property(nonatomic,retain)IBOutlet UITableView *tblSimpleTable;
  @property(nonatomic,retain)IBOutlet UIButton *btn;
  @property(nonatomic,retain)IBOutlet UIImageView *i;
  
  -(IBAction)btnClicked;
  @end 
  </code></pre>
  
  <p>.m</p>
  
  <pre><code>#import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  
  @synthesize btn;
  @synthesize tblSimpleTable;
  @synthesize i;
  
  -(IBAction)btnClicked{
      if (flag==1) {
          flag=0;
          tblSimpleTable.hidden=NO;
          i.hidden=YES;
      }
      else{
          flag=1;
          tblSimpleTable.hidden=YES;
          i.hidden=NO;
      }
  }
  
  // The designated initializer. Override to perform setup that is required before the view is loaded.
  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
      if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
          // Custom initialization
  
      }
      return self;
  }
  
  /*
   // Implement loadView to create a view hierarchy programmatically, without using a nib.
   - (void)loadView {
   }
   */
  
  
  
  // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  - (void)viewDidLoad {
      arryData = [[NSArray alloc] initWithObjects:@"iPhone",@"iPod",@"MacBook",@"MacBook Pro",nil];
      //tblSimpleTable.frame =CGRectMake(10, 10, 300, 100);
      flag=1;
      tblSimpleTable.hidden=YES;
      btn.layer.cornerRadius=8;
      tblSimpleTable.layer.cornerRadius=8;
      //i=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow-down.png"]];
      [super viewDidLoad];
  }
  
  
  
  /*
   // Override to allow orientations other than the default portrait orientation.
   - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
   // Return YES for supported orientations
   return (interfaceOrientation == UIInterfaceOrientationPortrait);
   }
   */
  
  
  - (void)didReceiveMemoryWarning {
      [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
      // Release anything that's not essential, such as cached data
  }
  
  
  
  
  #pragma mark Table view methods
  
  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
      return 1;
  }
  
  
  // Customize the number of rows in the table view.
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
      return [arryData count];
  }
  
  
  // Customize the appearance of table view cells.
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
  
      static NSString *CellIdentifier = @"Cell";
  
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (cell == nil)
      {
          cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] ;
      }
  
      // Set up the cell...
      cell.textLabel.text = [arryData objectAtIndex:indexPath.row];
      return cell;
  }
  
  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  }
  @end
  </code></pre>