Posted By

Mazzaroth on 02/19/11


Tagged


Versions (?)

Table View


 / Published in: Objective C
 

  1. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  2. return 2;
  3. }
  4.  
  5. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  6. NSInteger lNumberOfRows;
  7.  
  8. switch (section) {
  9. case 0:
  10. lNumberOfRows = 4;
  11. break;
  12. case 1:
  13. lNumberOfRows = 2;
  14. break;
  15. default:
  16. break;
  17. }
  18. return lNumberOfRows;
  19. }
  20.  
  21.  
  22. - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  23. NSString *lSectionTitle;
  24.  
  25. switch (section) {
  26. case 0:
  27. lSectionTitle = @"Security";
  28. break;
  29. case 1:
  30. lSectionTitle = @"Data";
  31. break;
  32. default:
  33. break;
  34. }
  35. return lSectionTitle;
  36. }
  37.  
  38.  
  39. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  40. static NSString *MyIdentifier = @"MyIdentifier";
  41. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
  42. if (cell == nil) {
  43. cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellAccessoryDetailDisclosureButton reuseIdentifier:MyIdentifier] autorelease];
  44. }
  45.  
  46.  
  47. switch (indexPath.section) {
  48. case 0:
  49. switch (indexPath.row) {
  50. case 0:
  51. cell.textLabel.text = @"Admin Password";
  52. break;
  53. case 1:
  54. cell.textLabel.text = @"User Management";
  55. break;
  56. case 2:
  57. cell.textLabel.text = @"Login Logs";
  58. break;
  59. case 3:
  60. cell.textLabel.text = @"Server";
  61. break;
  62. default:
  63. break;
  64. }
  65. break;
  66. case 1:
  67. switch (indexPath.row) {
  68. case 0:
  69. cell.textLabel.text = @"Datasets";
  70. break;
  71. case 1:
  72. cell.textLabel.text = @"Upload History";
  73. break;
  74. default:
  75. break;
  76. }
  77. break;
  78. default:
  79. break;
  80. }
  81.  
  82. return cell;
  83. }
  84.  

Report this snippet  

You need to login to post a comment.