04 October 2010

HelloWorld - Apple tutorial

After reading all the pre requisites for the "Your First iOS Application" guide on the Apple Developer Center, which was actually quite dry reading, I felt it was about time to crack on with the tutorial, on the basis that the theory may make a bit more sense after I've applied some of it.

The guide itself was a lot more complicated than the one I followed from the Stanford University course on iTunes U as it used a view controller for the GUI, rather than just adding the GUI elements to the background of the application. It is a lot more work on such a simple application, but I can see how it will benefit more complex applications.

One thing did continue to confuese me though with interface builder. I was using the handy blue dotted lines in interface builder to line up all my UI elements, the text field was showing as having a margin to the status bar at the top, however, when I ran the app in the iPhone emulator, the text field was butted right up against the status bar. This really confused me, as I double checked all the code, which was correct and couldn't imagine that Apple would show the status bar on the interface builder, then have it not accounted for when positioning the UI elements.

When I had convinced myself that I hadn't made some sort of school boy error, I consulted Google and came across a thread on the iPhone Dev SDK forum and saw that at least I wasn't the only person to have discovered this issue and that the following code needed to be added after the display has been drawn:
self.view.frame = [[UIScreen mainScreen] applicationFrame];

No comments:

Post a Comment