gpt4 book ai didi

ios - 无法将类型 'UIViewController.Type' 的值转换为预期的参数类型“UIViewController”

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

此代码显示错误:“无法将‘UIViewController.Type’类型的值转换为预期的参数类型‘UIViewController’”。请告诉我如何解决这个问题。

@objc static func listBtn()
{
drawerVw = DrawerView(aryControllers: DrawerArray.array, isBlurEffect: true, isHeaderInTop: false, controller: UIViewController.self)
//drawerVw = DrawerView(aryControllers: DrawerArray.array, isBlurEffect: true, isHeaderInTop: false, controller: self)
drawerVw.delegate = UIViewController.self as? DrawerControllerDelegate
//drawerVw.delegate = self
drawerVw.changeUserName(name: "New Delhi")
drawerVw.show()
}

最佳答案

您需要使用此代码。这段代码在我这边工作得很好。

@objc static func listBtn() {
UIViewController.showListButton(navigationController: navController)
}

扩展

import Foundation
import UIKit

extension UIViewController
{
static func showListButton(navigationController: UINavigationController)
{
if let currentVC = navigationController.visibleViewController
{
drawerVw = DrawerView(aryControllers: DrawerArray.array, isBlurEffect: true, isHeaderInTop: false, controller: currentVC)
drawerVw.delegate = currentVC as? DrawerControllerDelegate
drawerVw.show()
}
}
}

关于ios - 无法将类型 'UIViewController.Type' 的值转换为预期的参数类型“UIViewController”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49686299/

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