When you need to write a tedious interface but still a static page, you will probably use the Xib
"Exception: When creating a file that inherits from UIView, without the tick option to automatically generate XIB, developers need to manually new a xib file with the same name, selecting the appropriate file name in the class on the right side of the Xib file"
A few things to note:
(1) All controls in a xib can only be placed in their own @interface declaration, not in other files
(2) Learn to use the Init method properly, load xib, need to loadnibname, put in the Init method will be better, so that we can later add some other control settings in the Init method, when called in the controller only need to fill out the Init method , no need to worry that it is xib or pure code, use the following:
-(Instancetype) init{
self = [super init];
if (self) {
Here's the point:
self = [[[NSBundle mainbundle]loadnibnamed:@ "Jyemainactivitypageview" Owner:nil Options:nil] firstObject];
Some of the other settings can be written here
}
return self;
}
This is the case in the cell:
-(Instancetype) Initwithstyle: (Uitableviewcellstyle) style Reuseidentifier: (NSString *) reuseidentifier{
self = [super Initwithstyle:style reuseidentifier:reuseidentifier];
if (self) {
self = [[[NSBundle mainbundle]loadnibnamed:@ "Jyeminecell" owner:self Options:nil] lastobject];
Some other settings "if the contents of the cell are from model, you can also define a model property and make some other settings in his set method"
}
return self;
}
(3) or this: sign up and let your tableview know which cells it's looking for in the reuse pool.
[Self.tableview registernib:[uinib Nibwithnibname:nsstringfromclass ([Jyerecordcell class]) Bundle:nil] Forcellreuseidentifier:nsstringfromclass ([Jyerecordcell class])];
Jyerecordcell * Recordcell = [TableView dequeuereusablecellwithidentifier:nsstringfromclass ([Jyerecordcell class])];
About Xib need to pay attention to the place