Open dodikk opened 7 years ago
I'm going to add one more convenience constructor. See the code below. P.S. a pull request will follow.
public required init(controller: NMessengerViewController,
nibName: String,
bundle: Bundle)
{
super.init(controller: controller)
self.loadFrom(bundle: bundle, nibName: nibName)
}
fileprivate func loadFromBundle()
{
let nmessengerBundle = Bundle(for: NMessengerViewController.self)
let nibName = "NMessengerBarView"
self.loadFrom(bundle: nmessengerBundle, nibName: nibName)
}
fileprivate func loadFrom(bundle: Bundle,
nibName: String)
{
let nibObjects = bundle.loadNibNamed( nibName,
owner: self,
options: nil)
/*let fileOwnerSelf*/ _ = nibObjects?[0] as! UIView
self.addSubview(inputBarView)
inputBarView.frame = self.bounds
textInputView.delegate = self
self.sendButton.isEnabled = false
cameraVC.cameraDelegate = self
}
Another option is making open func loadFromBundle()
and forcing library users to subclass the NMessengerBarView
but that approach is less elegant, from my point of view.
As a library user I'm ok with the existing set of controls on
NMessengerBarView
but my designer wants a different layout. Moreover,NMessengerBarView
contains some useful camera and keyboard related logic.So I'd like to load the
NMessengerBarView
from my ownxib
and my own[NSBundle mainBundle]
(or from another one external toNMessenger
). So far, no extension points are available.