Stanford iPhone programming class 1st Demo – Why it fails in class
April 24, 2009 § 5 Comments
Stanford instructor asked the class to response and figure out the class demo on Slider. No one responded.
I reviewed all the comments from iphone developer forum on the Stanford iphone programming class 1st demo on Slider. Many class observers were complaining without figuring out the problems and couldn’t complete the project by following the class demo.
I gave a shot at it tonight. I solved it in 30min after experimenting a few things.
Stanford instructor forgot to add a UIView object outlet on Interface Builder. He placed the UILabel and UISlider on UIWindow directly.
This is my comment:
I feel Stanford instructor should have considered adding 2 extra slides explaining Interface Builder and UIKit framework before the class demo. If he would have explained it, he wouldn’t have forgotten an important step on Interface Builder.
UIWindow has no visual features. UIView class is a based class designed to support the drawing of the objects. UIWindow is functional like a picture frame and UIView class is serving as drawing canvas.
Imagine you are about to draw a house label and door slider. Only you discover there is no canvas to draw and show the drawing. The simulator shows black because it has no canvas to draw and render the objects.
First you need to add UIView from Library to the window first before you add UILabel and UISlider.
Add a new item on Identity Inspector on Interface Builder. Example:
You should have 3 object types:
Then you can control-drag the view to connect with “view” on the “window”.
Don’t forget to select “Write Class Files” under File Menu. This step will generate .h and .m files for controller.
Wishlist: I included the Xcode project here