Posted By

arpit on 05/25/09


Tagged

UITableView


Versions (?)

Table View Delegate


 / Published in: Objective C
 

  1. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  2. return 1;
  3. }
  4.  
  5.  
  6. // Customize the number of rows in the table view.
  7. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  8. return [resteraunts count];
  9. }
  10.  
  11.  
  12. // Customize the appearance of table view cells.
  13. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  14.  
  15. static NSString *CellIdentifier = @"Cell";
  16.  
  17. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  18. if (cell == nil) {
  19. cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
  20. }
  21.  
  22. // Set up the cell...
  23. NSString *cellValue = [[resteraunts objectAtIndex:indexPath.row] name];
  24. cell.text = cellValue;
  25.  
  26. return cell;
  27. }
  28.  
  29.  
  30. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  31. // Navigation logic may go here. Create and push another view controller.
  32. // AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
  33. // [self.navigationController pushViewController:anotherViewController];
  34. // [anotherViewController release];
  35. }

Report this snippet  

You need to login to post a comment.