Interface Builder

April 26th, 2009 by Chris Leave a reply »

interfacebuilder

dev_interfacemedium

Interface Builder is a great utility for new developers. As you might know, it’s used to design your user interface.

In fact, everything you create in Interface Builder you can also programmatically in Xcode. What is more Xcode given you more possibilities of customization any objects like sliders, toolbars, switches, images, text fields and more.

So what are advantages and disadvantages of using Interface Builder?

Disadvantages? None. Advantages? A lot of!

Interface Builder is a great utility that allows you to visually create an interface, not to guess what is the proper width, height and placement using X and Y coordinates. You can create almost every 2D game and application faster if using Interface Builder. It makes your code shorter – you don’t have to create the outlets manually, they are already created for you.

I will show you an example. How to create programmatically in Xcode a label:

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20.0, 50.0, 70.0, 30.0);];
label.textColor = [UIColor blueColor];
label.backgroundColor = [UIColor brownColor];
[label setText:@"My Text"];
label.textAlignment = UITextAlignmentCenter;
[self.view addSubview:label];

You will obtain the same result dragging & dropping the label from the I.B. Library to the view. Customization – like changing the text or background colour can be chosen from it’s menus, and while doing this, you track the changes and have full control if the new look matches the interface. But, customization is limited to keep I.B. window clear. You can’t rotate an label for example, but once you created an object and connected it to the right outlet Xcode can do the rest.

That was only an example. Interface Builder is really helpful and being a good programmer doesn’t mean the you have to use only Xcode. Relax, and play with I.B. every static content can be loaded from .xib files I.B. creates for you. Xcode will be necessary usually only if there is unknown number of objects to be displayed in the application.

Advertisement

2 comments

  1. Some cocos2d Porgrammer says:

    So what are advantages and disadvantages of using Interface Builder?

    Disadvantages? None. Advantages? A lot of!

    This is exagiration.

    What about?
    “Xcode will be necessary usually only if there is unknown number of objects to be displayed in the application.”

    Is’nt it that most of the GOOD games in the apple store requires undetermined dynamically created objects?

    cocos2d is for serious game programmers and Interface Builder is for interface rich appications.

    well this is my opinion based on experience

    • Chris says:

      Hi.
      Whenever I can I use Interface Builder, because I don’t have time to waste on design purposes only.

      For example tables, you cannot do much about tables using I.B., can you?

      Chris

Leave a Reply