Akshaykumar Maldhure
Akshaykumar Maldhure

Reputation: 1259

How to navigate to sw_front view using SWRevealViewcontroller in ios?

I am using SWRevealViewController to impliment sidebar in my ios app.I have followed appcoda tutorial to implement it.As per this tutorial I have made two segue's sw_front which is for main viewcontroller(rootviewcontroller) and second one is sw_rear which is for sidebar.I am successfully able to implement it using this tutorial,but now I am getting problem in navigating from sw_rear view to sw_front segue.Please, help me if anyone knows this kind of problem.

Upvotes: 4

Views: 3069

Answers (1)

Mina Fawzy
Mina Fawzy

Reputation: 21452

This my slidemenu.m

All you have to do Create table of your menu Items , Each item has identifier

Click right in each item , choose reveal view controller

that all enter image description here

    #import "SlideMenu.h"
    #import "SWRevealViewController.h"
    @interface SlideMenu ()

    @end

    @implementation SlideMenu{
        NSArray *menu_items;
        NSArray*thumbies;
        NSArray*indentifer;
    }


    - (id)initWithStyle:(UITableViewStyle)style
    {
        self = [super initWithStyle:style];
        if (self) {
            // Custom initialization
        }
        return self;
    }

    - (void)viewDidLoad
    {
        [super viewDidLoad];

        indentifer = @[@"report_view" ,@"ann_view" , @"message_view" , @"calendar_view" , @"schedule_view" , @"about_view" , @"student_view" ];

        menu_items = @[@"Reports" , @"Messages" , @"Announcement" , @"Calendar" ,@"Schedule" ,@"About us",@"back to Students"];

        thumbies = @[@"report.png" , @"message.jpg" ,@"ann.jpg", @"calendar.jpg" , @"schedule.png" , @"about.png" ];

    }



    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }

    #pragma mark - Table view data source

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {

        // Return the number of sections.
        return 1;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {

        // Return the number of rows in the section.
        return [menu_items count];
    }


    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSString * cell_identifer = [indentifer objectAtIndex:indexPath.row];
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cell_identifer forIndexPath:indexPath];

        if (cell== nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cell_identifer];
        }

        //cell.textLabel.text = [menu_items objectAtIndex:indexPath.row];
        //cell.imageView.image = [UIImage imageNamed:[thumbies objectAtIndex:indexPath.row] ];

        return cell;
    }





    #pragma mark - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        if ([segue isKindOfClass:[SWRevealViewControllerSegue class]]) {
            SWRevealViewControllerSegue *swsegue = (SWRevealViewControllerSegue*)segue;

            swsegue.performBlock = ^(SWRevealViewControllerSegue *rvc_segue , UIViewController * svc , UIViewController *dvc){
                UINavigationController *navController = (UINavigationController *)self.revealViewController.frontViewController;
                [navController setViewControllers:@[dvc] animated:NO];
                [self.revealViewController setFrontViewPosition:FrontViewPositionLeft animated:YES];
            };

        }
    }


    @end

UPDATE ANSWER FOR XCODE 6.4

FULL EXAMPLE

create viewController to hold SWRevealViewController class

this view has rear (slide menu items) , front (implemented items) please check screen shots

enter image description here

enter image description here

from your slide menu viewController class to each item

this table view implement my slide menu items , I use push method

(SWRevealViewControllerSeguePushController)

enter image description here

here is connection inspector before navigation controller

enter image description here

hope this answer all your questations

Upvotes: 1

Related Questions