gpt4 book ai didi

ios - 呈现 View Controller 的最佳方式

转载 作者:行者123 更新时间:2023-11-28 19:25:17 26 4
gpt4 key购买 nike

我正在研究多个框架,我的问题只是一个“哲学”问题。

我创建了一个实用函数来显示 View Controller

static func presentViewController(identifier: String, storyboardName: String = "Main", presentationStyle: UIModalPresentationStyle = .fullScreen){
let storyboard = UIStoryboard(name: storyboardName, bundle: InternalConstants.bundle)
var viewResult: UIViewController
if #available(iOS 13.0, *) {
viewResult = storyboard.instantiateViewController(identifier: identifier)
} else {
viewResult = storyboard.instantiateViewController(withIdentifier: identifier)
}
viewResult.modalPresentationStyle = presentationStyle
var top = UIApplication.shared.keyWindow?.rootViewController
while top?.presentedViewController != nil {
top = top!.presentedViewController
}
top!.present(viewResult, animated: true, completion: nil)
}

首先,这是呈现 View Controller 的正确方式还是有更好的方式?

那么,在导航 Controller 中呈现 View Controller 是否更好?

最佳答案

First of all, is a correct way to present a view controller or there is a better way?

而不是一个实用程序使它在里面

 extension UIViewController {
func ......
}

Then, is better to present a view controller in a navigation controller or not?

nav 面向 push/pop 但用它来呈现另一个 vc 也没有错

关于ios - 呈现 View Controller 的最佳方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59388497/

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