Jacqueline Judge

iOS UI Programming Start

03 Feb 2014

UI Programming Start on iOS – WORK IN PROGRESS - NOT DONE

I try to make basic UI programming as painless as possible - preferring to spend time on more interesting programming tasks. (Just look at this spartan blog - as an example!) It is much more fun to manipulate camera output or articulate the design for threading or other systems concepts.

My first concern - since I am a long time C++ programmer - is memory management. I decided to use Automatic Reference Counting, otherwise known as ARC. This article is part 1 of a tutorial on ARC, and this Dr Dobbs article explains ARC with a sample. The “Defining properties” as shown on this cheat sheet need to be understood. And as expected, ARC ignores memory allocation by stdlib and Core Foundation APIs. That memory has to be handled manually.

A UI Screen in iOS can be created entirely in code or via .xib or .storyboard xml files. This is a video of a debate on that issue. Frankly, I find that there is room for all three methods, and I am liking storyboard files (until I find more advanced situations that require more). Note that Apple prefers that we use storyboards. In this video about the Facebook build process, the speaker mentioned that they wrote the UI for their app entirely in code.

A storyboard contains xibs connected by segues - which make transitions between the xibs easier to handle. This Apple tutorial shows how to start. Look for the words “Identity inspector” to see how to link the created controller class with the storyboard. To make connections from UI elements to the class, use the control key as shown in the video on this page. The outlets represent the objects, and the actions are events for those objects.

If that seems daunting, note that the book, iOS 7 App Development by Neil Smyth, is awesome for getting started on UIs. That book shows a lot of things in detail if you are not used to the interface.

I am skipping many steps that I will write later.

This is a way to bring up the controller for a storyboard named Profile_iPhone.xib from an action event in a GUI.

ProfileViewController * profileViewController = [[UIStoryboard storyboardWithName:@"Profile_iPhone" bundle:nil] instantiateInitialViewController];
[self presentViewController:profileViewController animated:YES completion:nil];

This is a way to bring up the controller for a xib named Login_iPhone.xib from the AppDelete didFinishLaunchingWithOptions method:

self.loginViewController = [[LoginViewController alloc] initWithNibName:@"Login_iPhone" bundle:nil];
self.window.rootViewController = self.loginViewController;
[self.window makeKeyAndVisible];

I have a lot more to write and explain - and understand. I assume no one sees this yet.


Tweet   

Comments

comments powered by Disqus