【发布时间】:2019-02-20 20:25:27
【问题描述】:
我正面临一个严重的问题。我有一个名为“abc.framework”的框架,它包含一个函数,您可以在其中传递一个 viewController 对象。
//this is the method in my framework
func launchView(view:UIViewController){
}
//this is what needs to be written on App side
myFrameworkFile.launchView(view: self)
上述方法用于在传递的 viewController 对象之上呈现 Framework 的 viewController 即 abc.framework viewController。启动方法包含以下代码:
func launchView(view:UIViewController)
{
var rootController: UIViewController?
rootController = view
let storyboard = UIStoryboard(name: "abcFrameworkBundle.bundle/abcUIMain", bundle: nil)
let VC1 = storyboard.instantiateViewController(withIdentifier: "selectedviewcontroller") as! SelectedViewController
rootController?.present(VC1, animated: true, completion: nil)
}
从上面的方法中,viewController 的 SelectedViewController viewDidLoad 方法被调用,但是它没有被呈现,我收到以下警告
警告:尝试在 其视图不在窗口层次结构中!
有人遇到过同样的问题吗?
【问题讨论】:
-
this 会帮助你吗?无论如何,我会在你的框架类中创建静态方法,它会返回我的控制器实例。那么你可以在你的项目中做
let controller = SomeClass.instantiate(); present(controller, animated: true) -
你在哪里调用这个方法“launchView”?
标签: ios swift frameworks