I have this problem with creating UIView's
subclasses. Creating, for example, UIViewControllers
or UITableViewCells
is okay.
Why this happens?
Yes as per @PRECover, the xib check mark button is disabled always to help you more I am describing the steps to make it easy for you
Step - 1 : Create the UIView class without the xib.
Step - 2 : Go to create a new File and choose the Resource template this time
Step 4 - Now go to to the view class and write the "getView" function
class SampleView: UIView {
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect(rect: CGRect) {
// Drawing code
}
*/
func getView() -> UIView {
return NSBundle.mainBundle().loadNibNamed("SampleView", owner: nil, options: nil)[0] as! UIView
}
}
Step 5 - Write the method below and call that to add the view in the main View (where ever you want)
func designSampleView()
{
let sview = (SampleView()).getView();
NSLog("Test ", "");
self.view.addSubview(sview);
}
来源:https://stackoverflow.com/questions/39105607/also-create-xib-file-button-disabled