|
|
1
4
When nib file is loaded, it creates view controller of exactly the same class that is written in .xib (UIViewController, or PrimeViewController, whatever else). What actually is saved in your .nib file? You'll succeed if you will store UIView and all the corresponding objects in xib, and will load only them by using [[NSBundle mainBundle] loadNibNamed:@"YourNibFile" owner:class1ViewController options:nil], while view in nib is connected to the corresponding File owner outlet. |
|
|
2
2
If you put all your views in one NIB, then when your application launches, it has to load the entire NIB into memory and construct all of the objects for all of the controls, and this takes a lot of time. If you separate your views into separate NIBs, then your app will start up much faster, because only the NIB containing the initial view will be loaded. Then, when the view changes, you can load the NIB containing the new view. This will incur a minor hitch when opening a view for the first time. Also if you're trying to optimize memory usage, you can unload the precious view when switching to a view |
|
|
3
0
I'd suggest subclassing UITableViewController and add any methods, instance variables, and properties common to your different view here. Make your nib and have it have a reference to an instance of one of these objects. 然后,对子类进行子类化以获得定制的功能,比如
You should stick to overriding the designated initializer. Put any custom initialization code into awakeFromNib or viewDidLoad methods, depending on if they need to modify UIView objects. However, as others have mentioned, it's not terribly efficient or elegant. If all your ViewControllers are table view controllers and have the same data model to display, then there are other ways to get code reuse, like defining a datasource object. |
|
|
Serega · 界面生成器不会拉伸自定义视图的子视图 8 年前 |
|
|
Cue · NSTableView列标题不显示 8 年前 |
|
|
Hapeki · 覆盖UILabel字体会导致切断标签 8 年前 |
|
|
Ravi Panchal · 处理情节提要时,情节提要UI未更新 8 年前 |