Developing for iPhone

Learn how to create and develop iPhone applications from scratch.

Tagged with ‘label’

Tutorial 3-3: More Interface Connections

Posted by Henry On May - 2 - 2009 3 COMMENTS

Go ahead and open the “HelloiPhone” project from the previous tutorial. Remember the slider we added to the interface? Today we will give it some functionality.
Open “HelloiPhoneViewController.h” and edit it to look like this:

#import <uikit /UIKit.h>
 
@interface HelloiPhoneViewController : UIViewController {
	IBOutlet UILabel *sliderValue;
}
 
@property (nonatomic, retain) UILabel *sliderValue;
 
-(IBAction) sliderChanged: (id) s;
-(IBAction) goButton;
 
@end
 
</uikit>

Read the rest of this entry »

Tutorial 3-1: Hello iPhone!

Posted by Henry On April - 24 - 2009 1 COMMENT

Ah yes, the moment you have been waiting for. Time to write an iPhone application. If you have not completed the previous tutorials, I suggest you do that now.
Follow these steps to get started:

  1. In XCode, click File > New Project
  2. In the left pane of the new window, click Application under the iPhone OS heading
  3. In the right pane, click View Based Application and then click the Choose button
  4. Name the project “HelloiPhone” and click Save

You will notice that there are a few folders set up for you in the left pane of the project window. For now you don’t need to know what all the files in each folder do.
Click Build and Go. A new application will open called iPhone Simulator, and in it comes a nice shiny iPhone for you to play with. This is where you can test your applications. As soon as it loads, it will boot up the application that you just created. You haven’t done anything to it yet so it is just a gray screen. Press the home button (the square symbol at the bottom) to exit the application. Go ahead and play around with it – use it just like a real iphone but use your mouse to control it instead. Try clicking Hardware > Rotate Left or Right to flip the iPhone on it’s side.

There are some things that the iPhone simulator can’t do. It doesn’t include things like GPS to find it’s location or an accelerometer to detect movement or tilting. You also cant use multi-touch as you only have one mouse. For these things you will need to test on a real iPhone. However, you are only allowed to use a real iPhone if you have paid for and been accepted to Apple’s Standard Developer Program or higher. But for learning the basics, the simulator is fine.

Quit the simulator when you are done and return to XCode.

Read the rest of this entry »