So I have a nib file for my CustomViewController and every time I want to present this Controller I do
let vc = CustomViewController(nibName: "CustomViewController", bundle: nil)
self.present(vc, animated: true, completion: nil)
What I want is to make CustomViewController to load itself from nib by itself. So that the call in the parent VC would be like this
let vc = CustomViewController()
self.present(vc, animated: true, completion: nil)
In CustomViewController add this init method. it will works as per your need.
convenience init() {
self.init(nibName: "CustomViewController", bundle: nil)
}
试试这种方式....
MyViewClass *myViewObject = [[[NSBundle mainBundle] loadNibNamed:@"MyViewClassNib" owner:self options:nil] objectAtIndex:0]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.