1

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Oleksandr Karaberov
  • 12,573
  • 10
  • 43
  • 70

1 Answers1

6

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.

Andrew Madsen
  • 21,309
  • 5
  • 56
  • 97
  • Correct me if I'm wrong here, but wouldn't any attemps at XML manipulation prove frivolous once the xibs were compiled to nibs? – Mick MacCallum Oct 22 '12 at 02:43
  • Actually, @NSPostWhenIdle, I wrote a XIB XML reader. Not much is actually gone from the XIB when it compiles. – CodaFi Oct 22 '12 at 02:47
  • I presumed that the OP was asking about pre-compilation manipulation of XIBs, so the manipulated file would still be compiled down as normal. – Andrew Madsen Oct 22 '12 at 03:19