UITableView delegates


/ Published in: iPhone
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #pragma mark -
  2. #pragma mark Table view data source
  3.  
  4. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  5. // Return the number of sections.
  6. return 1;
  7. }
  8.  
  9.  
  10. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  11. // Return the number of rows in the section.
  12. return 0;
  13. }
  14.  
  15.  
  16. // Customize the appearance of table view cells.
  17. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  18.  
  19. static NSString *CellIdentifier = @"Cell";
  20.  
  21. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  22. if (cell == nil) {
  23. cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
  24. }
  25.  
  26. // Configure the cell...
  27.  
  28. return cell;
  29. }
  30.  
  31. /*
  32. // Override to support conditional editing of the table view.
  33. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
  34.   // Return NO if you do not want the specified item to be editable.
  35.   return YES;
  36. }
  37. */
  38.  
  39.  
  40. /*
  41. // Override to support editing the table view.
  42. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  43.  
  44.   if (editingStyle == UITableViewCellEditingStyleDelete) {
  45.   // Delete the row from the data source
  46.   [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
  47.   }
  48.   else if (editingStyle == UITableViewCellEditingStyleInsert) {
  49.   // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
  50.   }
  51. }
  52. */
  53.  
  54.  
  55. /*
  56. // Override to support rearranging the table view.
  57. - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
  58. }
  59. */
  60.  
  61.  
  62. /*
  63. // Override to support conditional rearranging of the table view.
  64. - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
  65. // Return NO if you do not want the item to be re-orderable.
  66.   return YES;
  67. }
  68. */
  69.  
  70.  
  71. #pragma mark -
  72. #pragma mark Table view delegate
  73.  
  74. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  75. // Navigation logic may go here. Create and push another view controller.
  76. /*
  77.   <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
  78.   // ...
  79.   // Pass the selected object to the new view controller.
  80.   [self.navigationController pushViewController:detailViewController animated:YES];
  81.   [detailViewController release];
  82.   */
  83. }
  84.  
  85. /*
  86. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  87.   return 44.0f;
  88. }
  89. */

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.