One, Xib and storyboard contrast
In common
1> are used to describe the software interface
2> are edited with the Interface Builder tool.
3> essence is converted into code to create the control
* Different points
1>xib is lightweight and is used to describe the local UI interface
2>storyboard is a heavyweight, a multi-interface for describing the entire software, and the ability to show jump relationships between multiple interfaces
Second, the loading method of Xib
Method 1:
Nsarray *views = [[NSBundle mainbundle] loadnibnamed:@ "xib file name" Owner:nil Options:nil];
Method 2:
uinib *nib = [uinib nibwithnibname:@ "xib filename" bundle:nil];
Nsarray *views = [nib Instantiatewithowner:nil options:nil];
Iii. steps to customize view with Xib
* New custom control class, inherited from UIView
* New Xib file (filename suggestion and view class name match)
* Modify the class name of view in Xib
* Package Xib loading process, the steps to read the Xib file are encapsulated in the class, because the Xib file name and the class name, so you can directly get the names of the class to use Nsstringfromclass (self)
1 + (Chaosshopview *) Shopview2{3 Chaosshopview *shopview = [[[ NSBundle Mainbundle] Loadnibnamed:nsstringfromclass (self) owner:nil options:nil] lastobject]; 4 return Shopview; 5 }
* Add model properties, set data to child controls in the set method of model properties
1 // 2 -( void ) Setshopmodel: (Shopmodel *) Shopmodel 3 4 // Override set method prerequisites, assign the passed variable to the member variable Span style= "color: #008080;" >5 _shopmodel = Shopmodel; 6 [_ Viewimage setimage:[uiimage ImageNamed:shopModel.icon]; 8 _namelabel.text = Shopmodel.name; 9 }
* Child control access can be defined in the extension class, with "Off-line" way to implement
iOS Edge learning--xib file First Use