Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. #import "RevealTableViewController.h"
  2. #import "SWRevealViewController.h"
  3. #import "PhotoViewController.h"
  4.  
  5. @interface RevealTableViewController ()
  6.  
  7. @end
  8.  
  9. @implementation RevealTableViewController {
  10. NSMutableArray *menuItems;
  11. NSMutableArray *detailitemlist;
  12. }
  13.  
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16.  
  17. menuItems = [[NSMutableArray alloc] init];
  18. [menuItems addObject:@"CART"];
  19. [menuItems addObject:@"WISHLIST"];
  20.  
  21. detailitemlist = [[NSMutableArray alloc]init];
  22. [detailitemlist addObject:@"NEW ARRIVALS"];
  23. [detailitemlist addObject:@"BRANDS"];
  24. [detailitemlist addObject:@"CLOTHING"];
  25.  
  26. }
  27.  
  28. - (void)didReceiveMemoryWarning {
  29. [super didReceiveMemoryWarning];
  30. // Dispose of any resources that can be recreated.
  31. }
  32.  
  33. #pragma mark - Table view data source
  34.  
  35. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  36.  
  37. return 2;
  38. }
  39.  
  40. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  41.  
  42. NSInteger n = 0 ;
  43. switch (section) {
  44. case 0:
  45. n = [menuItems count];
  46. break;
  47.  
  48. case 1:
  49. n = [detailitemlist count];
  50. break;
  51. }
  52. return n;
  53. }
  54.  
  55.  
  56. - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
  57. {
  58. NSString *sectionName;
  59. switch (section)
  60. {
  61. case 1:
  62. sectionName =@" CATEGORIES";
  63. break;
  64. }
  65. return sectionName;
  66. }
  67.  
  68.  
  69. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  70. if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
  71. [tableView setSeparatorInset:UIEdgeInsetsZero];
  72. }
  73. if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {
  74. [tableView setLayoutMargins:UIEdgeInsetsZero];
  75. }
  76.  
  77. static NSString *indictor = @"Cell";
  78. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indictor];
  79.  
  80.  
  81. if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
  82. [cell setLayoutMargins:UIEdgeInsetsZero];
  83. }
  84.  
  85. if (cell == nil){
  86. cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indictor];
  87.  
  88. }
  89. switch (indexPath.section) {
  90. case 0:
  91. cell.textLabel.text = [menuItems objectAtIndex:indexPath.row];
  92. break;
  93.  
  94. case 1:
  95. cell.textLabel.text = [detailitemlist objectAtIndex:indexPath.row];
  96. break;
  97. }
  98. return cell;
  99.  
  100. }
  101. #pragma mark - Navigation
  102.  
  103. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  104.  
  105. NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
  106. UINavigationController *destViewController = (UINavigationController*)segue.destinationViewController;
  107. destViewController.title = [[menuItems objectAtIndex:indexPath.row] capitalizedString];
  108.  
  109.  
  110. if ([segue.identifier isEqualToString:@"showPhoto"]) {
  111. UINavigationController *navController = segue.destinationViewController;
  112. PhotoViewController *photoController = [navController childViewControllers].firstObject;
  113. NSString *photoFilename = [NSString stringWithFormat:@"%@_photo", [menuItems objectAtIndex:indexPath.row]];
  114. photoController.photoFilename = photoFilename;
  115. }
  116. }
  117.  
  118. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement