gpt4 book ai didi

ios - SWRevealViewController 传递参数

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:00:28 33 4
gpt4 key购买 nike

通过 SWRevealViewController 将参数从一个 ViewController 传递到另一个 ViewController。这不是在Front Controller和Rear Controller之间传递参数,而是从另一个ViewController(firstViewController)到前端(frontViewController.请参阅图片以供引用。 segue(在按钮触摸时)尝试将字符串值传递给前端 Controller

图片在这里:http://portwire.com/stackoverflow/storyboard.png

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
SWRevealViewController *destinationViewController = (SWRevealViewController *)segue.destinationViewController;
UINavigationController *navegationController = (UINavigationController *)destinationViewController.frontViewController;

//UUPS!! SWRevealViewController.frontViewController is nil

//How to access destination UIViewController????????

FrontViewController * frontViewController = (FrontViewController *)navegationController.topViewController;
frontViewController.fromString = @"String from previous view";
}

最佳答案

对于 Swift 3.0:

  1. 您必须将 SWRevealViewController 的 storyBoardId 命名为您想要的任何名称,在此示例中:“SWRevealViewController”

  2. 遵循以下代码:

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let revealVc = storyboard.instantiateViewController(withIdentifier :"SWRevealViewController") as! SWRevealViewController
    revealVc.loadView()
    let navViewController = revealVc.frontViewController as! UINavigationController
    if (navViewController.topViewController?.isKind(of: MainVc.superclass()!)) {
    let mainVc = navViewController.topViewController as! MainVc
    mainVc.email = email
    }
    self.present(revealVc, animated: true, completion: nil)

关于ios - SWRevealViewController 传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24701633/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com