Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "RevealTableViewController.h"
- #import "SWRevealViewController.h"
- #import "PhotoViewController.h"
- @interface RevealTableViewController ()
- @end
- @implementation RevealTableViewController {
- NSMutableArray *menuItems;
- NSMutableArray *detailitemlist;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- menuItems = [[NSMutableArray alloc] init];
- [menuItems addObject:@"CART"];
- [menuItems addObject:@"WISHLIST"];
- detailitemlist = [[NSMutableArray alloc]init];
- [detailitemlist addObject:@"NEW ARRIVALS"];
- [detailitemlist addObject:@"BRANDS"];
- [detailitemlist addObject:@"CLOTHING"];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- #pragma mark - Table view data source
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 2;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- NSInteger n = 0 ;
- switch (section) {
- case 0:
- n = [menuItems count];
- break;
- case 1:
- n = [detailitemlist count];
- break;
- }
- return n;
- }
- - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
- {
- NSString *sectionName;
- switch (section)
- {
- case 1:
- sectionName =@" CATEGORIES";
- break;
- }
- return sectionName;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
- [tableView setSeparatorInset:UIEdgeInsetsZero];
- }
- if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {
- [tableView setLayoutMargins:UIEdgeInsetsZero];
- }
- static NSString *indictor = @"Cell";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indictor];
- if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
- [cell setLayoutMargins:UIEdgeInsetsZero];
- }
- if (cell == nil){
- cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indictor];
- }
- switch (indexPath.section) {
- case 0:
- cell.textLabel.text = [menuItems objectAtIndex:indexPath.row];
- break;
- case 1:
- cell.textLabel.text = [detailitemlist objectAtIndex:indexPath.row];
- break;
- }
- return cell;
- }
- #pragma mark - Navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
- UINavigationController *destViewController = (UINavigationController*)segue.destinationViewController;
- destViewController.title = [[menuItems objectAtIndex:indexPath.row] capitalizedString];
- if ([segue.identifier isEqualToString:@"showPhoto"]) {
- UINavigationController *navController = segue.destinationViewController;
- PhotoViewController *photoController = [navController childViewControllers].firstObject;
- NSString *photoFilename = [NSString stringWithFormat:@"%@_photo", [menuItems objectAtIndex:indexPath.row]];
- photoController.photoFilename = photoFilename;
- }
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement