gpt4 book ai didi

ios - Swift 中的 MMDrawerController 子类

转载 作者:行者123 更新时间:2023-11-29 01:23:43 25 4
gpt4 key购买 nike

如果您正在使用 Swift + CocoaPods + use_frameworks!使用 MMDrawerController 开源 (ObjC) 库,您可能无法子类化 MMDrawerController 并收到“未使用的初始化程序”的多个警告

您所要做的就是重写初始值设定项并调用 super。很简单,但是我在谷歌搜索这个问题时看到这个问题绝对没有,所以我只是想帮忙。我已经在下面发布了我的代码。

最佳答案

import UIKit
import MMDrawerController

class TRDrawerController: MMDrawerController {

private var recordsModel = TRRecordsModel.sharedInstanceOfRecordsModel
private var itemsModel = TRItemsModel.sharedInstanceOfItemsModel

init() {
let centerViewController = UIStoryboard(name: "TRMain", bundle: nil).instantiateViewControllerWithIdentifier("TRTrackerViewController") as! TRTrackerViewController
centerViewController.recordsModel = recordsModel
centerViewController.itemsModel = itemsModel
let firstNavigationController = TRNavigationController(rootViewController: centerViewController)

let rightViewController = UIStoryboard(name: "TRMain", bundle: nil).instantiateViewControllerWithIdentifier("TRSettingsViewController") as! TRSettingsViewController
rightViewController.recordsModel = recordsModel
centerViewController.itemsModel = itemsModel
let secondNavigationController = TRNavigationController(rootViewController: rightViewController)

super.init(centerViewController: firstNavigationController, leftDrawerViewController: nil, rightDrawerViewController: secondNavigationController)
self.openDrawerGestureModeMask = [.PanningCenterView]
self.closeDrawerGestureModeMask = [.PanningCenterView, .TapCenterView, .TapNavigationBar]
self.shouldStretchDrawer = false
}

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}

// Won't be utilizing this, I want the app to crash if this gets used
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

}

关于ios - Swift 中的 MMDrawerController 子类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34280646/

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