Iphone Developer

View Controllers Stanford CS193P iPhone Dev

From looking at the MyTabBar app from Lecture 7 you can see that ViewControllers can be created with IB or programatically, like many other things in Xcode/IB.  The important thing is that in IB its not flexible; the way i see it if you create it in IB youre pretty much stuck with the design but in Xcode you can add things based on variables you get from the user or a data source.  EXAMPLE:

1. I went thru a tutorial from where we created a tabBarController with 2 tabs and later on added a NavigationController to one of the tabs.  Basically i dragged a tabcontroller from the IB Library (default of 2 tabs) and a navController.  I then had to create the view controller class files manually with their xibs and connect the xibs to the respective class files.  But thats it, once theyre setup, i couldnt add more xib files.

2. With lecture 7, looking at the MyTabBar app i can see how easily to create a view programatically and that gives you the flexibility to create more views based on user response or dynamic data sources.

Iphone Developer

Presence1 CS193P Stanford iPhone Dev

This was a great assignment for me.  I was able to get the PersonListViewController up and running.  I started by:

a) Adding the navigationController ivar in the delegate file (h) and adding its view to the window (m) as well as releasing it in dealloc.  Remember its EITHER OR.

You EITHER add the nav or tab or table VIEWCONTROLLER as a CONTROL in the XIB FILE.

OR you add it in code, by ALLOC/INITING it in the Class File.

b) then i added the IBAction in the PersonListViewController (h) and implementing that method (m) by instantiating the PersonDetailViewController, pushing it to the stack and releasing it.  Creating in my mind the VIEW CONTROLLERS RULE 1: Instantiate, Push and Release! In the viewDidLoad i just added bells and whistles like the title and an edit button i read about somewhere.

c) in the midst of all this, IB which is very helpful but AWFULLY CONFUSING, i learned that when i drag a ViewController onto my mainwindow.xib file, NOT THE WINDOW ITSELF, i must create the outlet connection to the delegate.  Furthermore, each new view controller must be classed for it to work and finally connect each Nib.  This is a simple task but obscure really, so i came up with the VIEW CONTROLLERS RULE 2: Create Class, Class it and Nib it!

d) Finally in the PersonDetailViewController, you add the iVars for logic and IBOutlets.  Create properties for some, but not others (why?) and any methods which here included the initWithNibName including the tag property whose button object had to be declared BEFORE calling initWithNibName.  Then in viewDidLoad code the logic including the if tag = 1 display this, not that.  The reason i see why you would only create properties and synthesize the imageview and int is because they form part of objects; UIImage and UIButton respectively whereas label and status are just variables given some value.

e) In IB, File Owner gets all the received actions and outlets to view.  Views get the outlets for buttons from being told which class that nib belongs to because in that class definition is where the IBOutlets are defined.  So basically the MainWindow.nib with, File Owner connects to delegate who connects to window and root navigation controller.  Each VC after that must belong to a class of its own and is connected up to the root navigation controller via the views which are pushed onto the main stack and added to the window of the MainWindow.nib.

Iphone Developer

Stanford Assignment 3 HelloPoly: 1 Control/Multiple Actions

I should have known this from my experience in Flash!  The solution to why it only draws the first polygon is that the same buttons, Increase and Decrease, required multiple, in this case 2, actions, not just one.  Basically you need to define another method, inside the polygonview, which calls setNeedsDispaly.  And hook up the same buttons in the nib file to that method.

Translate »