gpt4 book ai didi

ios - 继续引用

转载 作者:行者123 更新时间:2023-11-30 14:09:08 28 4
gpt4 key购买 nike

我试图通过自定义类从一个按钮连接到另一个 Storyboard中的新 View Controller 。这就是自定义类的外观。

import UIKit
import Foundation

class NavigationController{

static func segueToNextViewController(#storyboardName: String){
var eventsBoard: UIStoryboard = UIStoryboard(name: storyboardName, bundle: NSBundle.mainBundle())
var nextViewController = eventsBoard.instantiateInitialViewController() as! UIViewController
self.presentViewController(nextViewController, animated: true, completion: nil)
}
}

但是我遇到了一个错误:“NavigationController.Type”在此行上没有名为“presentViewController”的成员 self.presentViewController(nextViewController,animated:true,completion:nil)

任何帮助将不胜感激

最佳答案

试试这个,

import UIKit
import Foundation

class NavigationController{

func segueToNextViewController(storyboardName: String){
let storyboard = UIStoryboard(name: storyboardName, bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("#YourViewControllerName") as! UIViewController
self.presentViewController(vc, animated: true, completion: nil)
}
}

*确保为您的 View Controller Storyboard ID 命名,并将相同的名称粘贴到代码中的 #YourViewControllerName

关于ios - 继续引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31964167/

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