![]() |
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. |
![]() |
Lorenzo Zorri · 如何根据文本字段的内容动态调整其宽度? 9 月前 |
![]() |
Rashik · 为什么Spacer()会自动扩展我的VStack 1 年前 |
![]() |
lucycoco · 如何解决pod安装问题并成功运行pod安装? 1 年前 |
![]() |
Viktor Sec · 如何自动将字符串添加到Xcode字符串目录? 1 年前 |
![]() |
Rue Vitale · 定位UILabel 1 年前 |