user1744056
user1744056

Reputation:

How to dynamically change Interface Builder xib files by writing Objective-C code?

Today I'm writing my first "Hello World" application for iOS. And I wondered how can I manipulate .xib files programmatically similar to Android XML layout files or XAML? I also want Interface Builder dynamically display changes. For example I have a .xib file "LoginPageView.xib", where I have buttons and other controls which I added via Interface Builder constructor, then I connect this .xib to the private class extension of "LoginPageViewController" in .m file. And now I want to add a new button programmatically: UIButton *button = [[UIButton alloc] initWithCGRect:...]; or I want to change button's background and so on.

The only way I know is to implement it in viewDidLoad method but if I do this my changes will display only when program run and I want Interface Builder dynamically display these changes before compiling. So the question is there some way in Xcode IDE to implement this and instructions how to do this?

Upvotes: 1

Views: 990

Answers (1)

Andrew Madsen
Andrew Madsen

Reputation: 21373

The short answer is no, this is not possible. The long answer is that you could possibly implement such a thing by reverse engineering the .xib file format (which is XML), and figuring out how to write it yourself. It would be far more trouble than it is worth.

Upvotes: 6

Related Questions