1

我正在使用 MMDrawerController 在我的 ios 应用程序中创建一个侧边栏,我已经成功实现了它,但是我试图在侧边栏显示时减少中心视图的 alpha,正如您通常在大多数具有类似功能的应用程序上看到的那样,但是我我收到错误

Type of expression is ambiguius without more context

这是我的 AppDelegate 中的代码,visualstateblock 部分正在抛出错误

func buildNavigationDrawer()
{

    // Instantiate Main.storyboard
    let mainStoryBoard:UIStoryboard = UIStoryboard(name:"Main", bundle:nil)

    // Create View Controllers
    let mainPage:TabBarViewController = mainStoryBoard.instantiateViewController(withIdentifier: "TabBarViewController") as! TabBarViewController



    let rightSideMenu:HomeSideMenuViewController = mainStoryBoard.instantiateViewController(withIdentifier: "HomeSideMenuViewController") as! HomeSideMenuViewController



    // Wrap into Navigation controllers

    let rightSideMenuNav = UINavigationController(rootViewController:rightSideMenu)

    // Cerate MMDrawerController
    drawerContainer = MMDrawerController(center: mainPage, rightDrawerViewController: rightSideMenuNav)

    //drawerContainer!.openDrawerGestureModeMask = MMOpenDrawerGestureMode.PanningCenterView
    drawerContainer!.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.panningCenterView

    drawerContainer!.setDrawerVisualStateBlock { (drawerContainer, rightSideMenuNav) in
        drawerContainer!.centerViewController.view.alpha = 0.3;
    }
    // Assign MMDrawerController to our window's root ViewController
    window?.rootViewController = drawerContainer

}

谢谢你的帮助

4

1 回答 1

1

setDrawerVisualStateBlockreturn中不是可选的,但它后面MMDrawerController仍然有一个 force wrapper!

这是告诉编译器从上一行(您创建的那个)中获取可选值

要解决此问题,请更改变量名称之一或使用以下命令:

drawerContainer?.setDrawerVisualStateBlock { $0.0.centerViewController.view.alpha = 0.3 }
于 2017-08-09T08:03:25.777 回答