I am trying to load a xib filed called "AddProgramView" using loadnibnamed when a user presses a button. I created the xib in storyboard, placed various subviews within the xib view, and hooked up outlets to a corresponding swift file named AddProgramView. When I load the xib, none of the subviews appear. They are all missing. Help? Here's my code
Within my main view controller:
@IBAction func addProgram(sender: UIButton) {
if let _ = addProgramView {
addProgramView!.frame = CGRectMake(0, self.window!.frame.origin.y + self.window!.frame.height, self.window!.frame.width, CGFloat(325))
}
else {
let addProgramViews = NSBundle.mainBundle().loadNibNamed("AddProgramView", owner: self, options: nil)
addProgramView = addProgramViews.first as? AddProgramView
addProgramView!.frame = CGRectMake(0, self.window!.frame.origin.y + self.window!.frame.height, self.window!.frame.width, CGFloat(325))
window?.addSubview(addProgramView!)
}
window?.bringSubviewToFront(addProgramView!)
UIView.animateWithDuration(0.3, delay: 0.0, options: UIViewAnimationOptions.CurveEaseOut, animations: {
self.addProgramView!.frame.origin.y -= CGFloat(325)
}, completion: nil)
}
The AddProgramView.swift file:
class AddProgramView: UIView {
@IBOutlet weak var nameField: UITextField!
@IBOutlet weak var cancelButton: UIButton!
@IBOutlet weak var instructionsLabel: UILabel!
}