Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between using xib and adding via code - iPhone

Tags:

ios

iphone

xib

What is the difference between using xib and adding page elements via code?

How the memory is allocated if I am using an xib?

like image 418
Dev Avatar asked Aug 14 '26 19:08

Dev


2 Answers

What is the difference between using xib and adding page elements via code?

The only real difference I know about is that using code is awesome and is recommended for beginners in order them to understand how UIKit works.

How the memory is allocated if I am using an xib?

Just like as if you were creating the objects manually, except that, for example, it won't be your view controller that performs [[UIImageView alloc] init] but a default factory class in UIKit (most likely some private subclass of NSCoder).

There is one major non-obvious difference between using XIB versus code for object creation/layout: Interface Builder does not offer settings for every property of every interface class type -- for some properties you just need to use code.

Some things are difficult/cumbersome or even impossible to do in interface builder, but are trivial to do in code. Back at least in the ios3/4 days, setting up a navigation controller along with customizing its title bar in interface builder was a real pain -- I always used code for this.

like image 41
Bogatyr Avatar answered Aug 17 '26 08:08

Bogatyr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!