我如何在swift中实现单例类,将uiview作为基类

时间:2016-02-20 09:26:01

标签: swift singleton

我正在尝试创建一个基类为uiview的单例类,但是我收到了这个错误:

  

无法为没有参数的“SecondView”类型调用初始化程序

import UIKit
class SecondView: BaseView {

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect(rect: CGRect) {
    // Drawing code
}
*/

static let secondViewSharedInstance = SecondView()
//MARK: - Custom Initialization
internal init(frame: CGRect, OnActions:(ScreeenType:NSInteger) -> ()){

    super.init(frame: frame)
}

required init?(coder aDecoder: NSCoder){
    super.init(coder: aDecoder)
}

}

如何解决此问题?当我接受新项目并复制此代码时它工作正常但在我的主项目中我得到了上述错误

我采用了基本视图

import UIKit
class BaseView: UIView {
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect(rect: CGRect) {
    // Drawing code
}
*/

var OnActionsRef : (ScreeenType:NSInteger) -> () = {_ in };
}

0 个答案:

没有答案