如果您使用的是 Swift + CocoaPods + use_frameworks!使用 MMDrawerController 开源(ObjC)库,您可能无法子类化MMDrawerController
获取“未使用的初始化程序”的多个警告
您所要做的就是覆盖初始化程序并调用 super。很容易,但我看到在谷歌搜索这个问题时,这个问题绝对没有,所以我只是想帮忙。我已经在下面发布了我的代码。
如果您使用的是 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")
}
}