Move to other View with RESideMenu

546 Views Asked by At

I have implemented RESideMenu in my app written in Swift and its implementation is perfect, I can not, however, to move the selection to other View when I click on the cell that has the name of the View choice (example: if I click Profile me error and as well as on other cells.

here is the code that I have converted into swift:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

    println("did select row: \(indexPath.row)")

    if (indexPath.row == selectedMenuItem) {
        return
    }

    selectedMenuItem = indexPath.row

    let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main",bundle: nil)

    var salViewController : UIViewController

    //sideMenuViewController!.setContentViewController(salViewController, animated: true)

    switch (indexPath.row){
    case 0:
        salViewController = mainStoryboard.instantiateViewControllerWithIdentifier("Home") as UIViewController
        break
    case 1:
        salViewController = mainStoryboard.instantiateViewControllerWithIdentifier("Profilo") as UIViewController
        break
    default:
        break

    }

}

and this is what obj-c:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath      *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
switch (indexPath.row) {
    case 0:
        [self.sideMenuViewController setContentViewController:[[UINavigationController    alloc] initWithRootViewController:[[DEMOFirstViewController alloc] init]]
                                                     animated:YES];
        [self.sideMenuViewController hideMenuViewController];
        break;
    case 1:
        [self.sideMenuViewController setContentViewController:[[UINavigationController    alloc] initWithRootViewController:[[DEMOSecondViewController alloc] init]]
                                                     animated:YES];
        [self.sideMenuViewController hideMenuViewController];
        break;
    default:
        break;
   }

}

How can I fix? I rely on you experts.

1

There are 1 best solutions below

0
On
    switch (indexPath.row) {
    case 0 :
        println("case 0")
        self.sideMenuViewController.setContentViewController(UINavigationController(rootViewController: self.storyboard?.instantiateViewControllerWithIdentifier("firstViewController") as! UIViewController)
            , animated: true)

            self.sideMenuViewController.hideMenuViewController()

        break
    case 1 :
        println("case 1")
        self.sideMenuViewController.setContentViewController(UINavigationController(rootViewController: self.storyboard?.instantiateViewControllerWithIdentifier("secondViewController") as! UIViewController)
            , animated: true)
        self.sideMenuViewController.hideMenuViewController()
        break
    default:
    break