0

我已经在我用 Swift 编写的应用程序中实现了 RESideMenu 并且它的实现是完美的,但是当我单击具有视图选项名称的单元格时,我无法将选择移动到其他视图(例如:如果我单击配置文件我的错误以及其他单元格上的错误。

这是我转换成 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

    }

}

这就是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;
   }

}

我该如何解决?我依靠你们的专家。

4

1 回答 1

0
    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
于 2015-07-12T01:19:13.630 回答