Game Development Reference
In-Depth Information
While I'm at it, if you need a refresher or introduction to views and windows, take a
look at Apple's View Programming Guide for iOS:
Note Unfortunately, you can't use Interface Builder to design your cocos2d
view. For that you have to use a separate editor like CocoShop, CocoaBuilder,
LevelHelper, or any other editing tool with cocos2d support that fits your need.
See Chapter 17 for a list of cocos2d editing tools.
For now, it's sufficient to just add any views to the Interface Builder view, like sliders,
buttons, labels, and whatnot. But ideally you should at least do the following: select the
main view and bring up the Attributes Inspector via View Utilities Attributes In-
spector. The first attribute under Simulated Metrics is called Orientation, and you
should change that to Landscape because the application is currently only capable of
running in Landscape mode. If you don't do that, your views will be rotated by 90 de-
grees when you run the application.
The MyView class doesn't need to be modified; the default implementation works just
fine. You can directly load the MyView.xib file by adding the following code at the
end of the addSomeTextFields method:
// add an Interface Builder view
MyView* myViewController = [[MyView alloc] initWithNibName:@"MyView" bundle:nil];
[window addSubview:myViewController.view];
[window sendSubviewToBack: myViewController.view]; // optional
Notice that the initWithNibName takes the name of the xib file as a parameter but
without the .xib extension. If you add the extension, you'll receive an error message
that the xib could not be loaded. The bundle parameter is nil , which means the app
should look for the file in the main bundle.
Because the MyView class inherits from UIViewController , you can access the
actual view with the myViewController.view property. You'll add that to the
Search Nedrilad ::

Custom Search