2

我正在尝试prepareForSegueSWRevealViewControllerSwift 写信。这是我的代码:

override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!)
{
    if(segue!.identifier == "segueName")
    {
        var someText = "Text"
        var rvc:newViewController = segue!.destinationViewController as newViewController
        rvc.topText = someText
    }
}

newViewControllertopTextNSString

当然,我得到了 nil 文本,因为我应该制作SWRevealViewControllerSegue,但我不知道它在 Swift 中的外观

4

4 回答 4

2

我找到了解决方案。

首先需要配置SWRevealControllerSegue。迅速它应该看起来像:

    if(segue.isKindOfClass(SWRevealViewControllerSegue))
    {
        var rvcs: SWRevealViewControllerSegue = segue as SWRevealViewControllerSegue
        var rvc:SWRevealViewController = self.revealViewController()

        rvcs.performBlock = {(rvc_segue, svc, dvc) in
            var nc:UINavigationController = dvc as UINavigationController
            rvc.pushFrontViewController(nc, animated: true)
        }
    }

第二。XCode 测试版现在IBOutletsegue这样的情况很糟糕。有了变量,一切都很好。

于 2014-07-11T12:04:22.697 回答
2
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

    if(segue.isKindOfClass(SWRevealViewControllerSegue))
    {
        var rvcs: SWRevealViewControllerSegue = segue as SWRevealViewControllerSegue
        var rvc:SWRevealViewController = self.revealViewController()

        rvcs.performBlock = {(rvc_segue, svc, dvc) in
            var nc:UINavigationController = self.revealViewController().frontViewController as UINavigationController
            nc.setViewControllers([dvc], animated: true)
            self.revealViewController().setFrontViewPosition(FrontViewPositionLeft, animated: true)
        }
    }

}
于 2014-09-19T08:23:49.330 回答
1

这不适用于最新版本。发行说明指出:

采用更简洁的方法来支持故事板。SWRevealViewControllerSegue 现在已弃用,您应该改用 SWRevealViewControllerSegueSetController 和 SWRevealViewControllerSeguePushController。

不过,我在任何地方都找不到任何快速的例子来解释这一点。

performBlock 方法不再存在。

感谢任何帮助。目前,如果不先学习目标 c,似乎不可能快速完成 :)

于 2015-04-22T08:41:57.977 回答
0

是什么newViewController?这应该有效:

override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!)
{
    if(segue.identifier == "segueName")
    {
        let someText = "Text"
        let rvc = segue.destinationViewController as SWRevealViewController
        rvc.topText = someText
    }
}
于 2014-07-10T13:00:12.280 回答