Beginning Your iPhone Programming Journey

An Introductory Chapter from EDUmobile.ORG iPhone & iPad Development Training Program
(now with a bonus chapter on iPad Development)

Copyright © 2009 – 2010 EDUmobile.ORG All Rights Reserved

NOTICE: You Do NOT Have the Right to Reprint or Resell This eBook!
You Also MAY NOT Give Away, Sell or Share the Content Herein
Copyright © 2009 – 2010 EDUmobile.ORG

ALL RIGHTS RESERVED. No part of this ebook may be reproduced or transmitted in any form whatsoever, electronic, or mechanical, including photocopying, recording, or by any informational storage or retrieval system without the expressed written, dated and signed permission from the author.

LIMITS OF LIABILITY / DISCLAIMER OF WARRANTY The authors and publisher of this book have used their best efforts in preparing this material. The authors and publisher make no representation or warranties with respect to the accuracy, applicability, fitness, or completeness of the contents of this program. They disclaim any warranties (expressed or implied), merchantability, or fitness for any particular purpose. The authors and publisher shall in no event be held liable for any loss or other damages, including but not limited to special, incidental, consequential, or other damages. This manual contains material protected under International and Federal Copyright laws and Treaties. Any unauthorized reprint or use of this material in prohibited.

Copyright © 2009 – 2010 EDUmobile.ORG All Rights Reserved

Beginning Your iPhone Programming Journey
Every once in a while a new opportunity arises due to a revolutionary technology and business model which is years ahead of the current scenario. Apple has done exactly that with its iPhone and iPod products, content delivery mechanism and business model that has leveled the playing field between big, small and individual businesses. Those of us who move quickly to learn the technology are the ones who will benefit the most from it, before ideas are taken by others and before the market gets too saturated, making it harder to succeed. You may have a very exciting idea and a passion to learn the tricks of coding like the gurus, but the due to limited iPhone development tutorials online and lack of well structured courses, your journey may probably not take off at all. As a result, your idea that could become the next blockbuster application on the App Store – will never happen and remain just a dream. And, its not really your fault… as there are currently no affordable online iPhone development courses that teach you through real tutors who guide you through step by step.

This is where the iPhone Course offered at EDUmobile.ORG comes in… Over a period of 12 weeks you will learn the topics step by step and start coding like the iPhone gurus. We will teach you through the following mediums Weekly Online Videos that you can download and view at your convenience Access to Real Tutors to help you solve coding or conceptual issues, on a one-on-one basis Weekly Worksheets and Exercise for you to do with challenging examples that are set up with just the right learning curve Access to an Online Form for discussing issues and meeting other students. One or Two Live industrial projects at the end of the course Plus you get a full 30 days no questions asked full money back guarantee. All this said, now lets get started …

Copyright © 2009 – 2010 EDUmobile.ORG All Rights Reserved

First things first… is the iPhone Programming Course right for me?
Before starting your journey, you must understand what is needed and expected of you to finish the course successfully. If you have absolutely no knowledge of programming, it will be very hard – although not impossible. Since, this is a programming course, you will be better prepared if you have programmed before – in any language. It does not matter if you programmed in Java, C or Scripted websites. As long as you know the basics you are good to go. However if you are not a programmer, but are up to the challenge, then you must ask yourself if you will be programming yourself - or will you go through this course to eventually become a producer for an iPhone product.

All said - a very basic knowledge of programming is a must. I suggest that you try to learn just basic C or python to quickly learn the programming nuances and concepts. If you are from a completely non-programming background, you may need a week to 1 month to catch up with the basics depending on the time you spend on learning. So, in order to get started comfortably with this course, you should be able to understand the following concepts before you go forward What are data types? What are operators? What are conditionals? What are loops? What are arrays and strings? What are objects? What are methods? I’ll stop at that, for now. This should be more than enough.

Copyright © 2009 – 2010 EDUmobile.ORG All Rights Reserved

if not all.ORG All Rights Reserved . you can continue brushing up your programming fundamentals in parallel to the iPhone course. if you need to review some of these concepts.I suggest you know at least a few of the above. and they should not sound completely alien to you! Of course. Either way … you need to do some homework before you start the iPhone Programming course! Copyright © 2009 – 2010 EDUmobile.

By developing with the Cocoa touch frameworks you will be writing applications the same way that iPhone OS itself is written. Now if you don’t understand what is reflective. You need to learn various aspects of the touch framework to master the iPhone programming. If you have programmed for Mac before you already know Objective C and for those who are new Objective C you can think Objective C to be child of C programming language and a distant cousin of C++. It was developed by Brand Cox and Tom Love for their company StepStone.How is the Course Structured? The iPhone Course is structured to teach you and focus on the following Objective C Cocoa Touch Framework iPhone SDK iPhone APIs Objective C Objective C is a programming language which will be used to program on the iPhone.ORG All Rights Reserved . which adds Smalltalk-style messaging to the C programming language. Cocoa Touch Framework Cocoa touch is Apple's name for the collection of frameworks. It will be discussed soon and you will cross these mole hills before you actually climb the mountain. and accompanying runtimes that make up the development layer of iPhone OS. According to Wikipedia Objective-C is a reflective. with controlled access to the the operating system. object oriented and messaging there is no need to panic. object-oriented programming language. APIs. Copyright © 2009 – 2010 EDUmobile.

The other iPhone specific components that you need to learn is SQLite .iPhone SDK The iPhone SDK consist primarily of Xcode and Interface Builder. Accelerometer. phone and media playing APIs. It helps creating faster interface for your application with minimal coding thus reducing the development time considerably. iPhone APIs Additionally to Cocoa there are other libraries such as OpenGL es which you need to learn to give your application that extra punch which can knock down the competition. It has been extended to support the iPhone and iPod programming. The Xcode is all season complete SDK for building MAC software. The other tool that will be used very often is called the interface builder. Core animation. Copyright © 2009 – 2010 EDUmobile.ORG All Rights Reserved .

com/iphone after registering at the portal. For but we suggest you do that later. you can optionally join the developer program for $99 only. You need to click and start the Xcode to create your first application. Once the Xcode is installed. If you want. Copyright © 2009 – 2010 EDUmobile. Alternatively. Installing the SDK Download the SDK from http://developer.Understanding The iPhone SDK The first thing we need to do to get started is to setup our coding environment on our computer. we need to download and install the iPhone SDK on our Mac or the Virtual OS on our Windows PC. you can search for Xcode in Finder and can start things from there. The registration is free.ORG All Rights Reserved . it will appear in the dock as shown below.

Once Xcode is started.ORG All Rights Reserved . close the smaller window. do the following…. the following screen will be visible on your desktop… Now. and you are ready to start programming for iPhone! Next. below - Copyright © 2009 – 2010 EDUmobile. Access – File >> New Project … and a new project template window will be displayed as shown on the next page.

ORG All Rights Reserved .Copyright © 2009 – 2010 EDUmobile.

. if you do not need any hand holding and you want to create an application from scratch. However. we will use standard templates to create our applications. These templates are handy to use and more often than not. . you may use the windows based application.. and give a name to the Application as “Hello World” .ORG All Rights Reserved .You will see that there are ready made templates for creating applications. For our example today we will select … “View Based Application”. The following screens will appear… Copyright © 2009 – 2010 EDUmobile.

ORG All Rights Reserved .However. So what exactly is Xcode IDE ? Xcode IDE primarily can be narrowed down to three major parts in addition to the Menu. before we start any work on our application we need to familiarize ourselves with the Xcode IDE. They are … The Top Bar The Side bar The code editor Copyright © 2009 – 2010 EDUmobile.

1. We will use it more in a later part of our course. The Top Bar This customizable bar provides shortcuts to menu elements. and looks like this… 2. The Side Bar This bar displays the directory structure of the current project. It looks like this … Copyright © 2009 – 2010 EDUmobile.ORG All Rights Reserved .

You can access the files from the side bar by clicking them and it will show up in the content window. Copyright © 2009 – 2010 EDUmobile.ORG All Rights Reserved . The Code Editor The other major part is the code editor.3. The content area is where you write your code.

Before we discuss the View Controller we must tell you that View is necessary to draw content on the iPhone. Copyright © 2009 – 2010 EDUmobile. These classes are… Hello_WorldAppDelegate. In short you can consider the Delegate as the Shell which enables the application.Application Architecture . Xcode create lots of code and component for us.m These are all Objective C files. In fact each iPhone Application has one window and can have multiple views. each playing a designated role in the project. A view is drawn over a window and in most of our practical applications we will be dealing with views only. So the two classes Delegate and View Controller are also divided into respective “. Through in this article we will not get into the details of these files but. for clarity of purpose. We know that “.ORG All Rights Reserved .h” and “.m Hello_WorldViewController.m” files. The Delegate class is the class which listens to the Applications running.h” files in objective C are for deceleration and “. Let us have a detailed look into this code.h Hello_WorldAppDelegate. we will define the work assigned to these classes. This class actually starts the application and exists all through the life cycle of the application. If we click on the Classes folder on the left panel we will see the classes that have been created by the Xcode. The View Controller is very specific to view based application that we have selected.A Sample Application When we created the views based project. Application passes messages on to the delegate through its life cycle which is handled and acted upon by it.h Hello_WorldViewController.m” files have the implementation details.

Now. Before we look into the code let us just do a bit of Objective C.The interface in objective C is use to declare the methods and data elements of the class. @class .The property and synthesize directive add getter and setter function to the class. A getter and setter function is use to assign and obtain values to an object. Auto Generated Code Example Let us now have a detail look into the code generated by the Xcode.The implementation defines the methods that were declared earlier using the interface.ORG All Rights Reserved . We have briefly clarified most of the major concepts.Declares the methods defined elsewhere. Copyright © 2009 – 2010 EDUmobile. it contains most of the object oriented features like Data Encapsulation. @implementation . However. When we use @synthesize we do not have to explicitly define a get and set function for the object properties it just get internally defined by the system. let us talk about some important concepts which are there is the code below @interface .A view is something that is visible to user and the controller decides what should be shown on the view. It is quite different from C++ in terms of its syntax and is rather similar to Smalltalk. This architecture is similar to the MVC architecture where we use model view and controller components to create our application. It is less memory intensive than an #import statement and in a compact device like iPhone it will used more often than mac applications. you can read through it. Objective C is Objects added to C. @property and @synthesize . as of now. However. In order for it to make any sense you must understand ObjectiveC. even if you are not familiar with this. Polymorphism and Inheritance.

We will discuss it in detail in later weeks. It lets the Interface builder know of the object. } @property (nonatomic. here is the code snippet… AppDelegate. Now that you are familiar with the above concepts. IBAction . @end Explanantion of the code above… The Above delegate class starts with defining a class directive for view controller.It is the trigger which is called from an Interface builder UI object. As discussed above it does that to import the definitions from view Controller class. @property (nonatomic.It is a special instance variable that references another object. Hello_WorldViewController *viewController.ORG All Rights Reserved . @interface Hello_WorldAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window. retain) IBOutlet UIWindow *window. The Next line uses a concept called as Protocol @interface Hello_WorldAppDelegate : NSObject <UIApplicationDelegate> A protocol is list of methods shared between classes. retain) IBOutlet Hello_WorldViewController *viewController.IBOutlet .h @class Hello_WorldViewController. Copyright © 2009 – 2010 EDUmobile. UIApplicationDelegate is the protocol and the NSObject is the parent class of Hello_WorldAppDelegate.

m #import "Hello_WorldAppDelegate. This concludes our explanation of AppDelegate.h" @implementation Hello_WorldAppDelegate @synthesize window. We will talk about them a bit later. [super dealloc]. } . . [window makeKeyAndVisible]. } @end Copyright © 2009 – 2010 EDUmobile. [window release]. lets Move on to our Second code example AppDelegate.Next.h code. we create object of UIWindow and View controller. Now.(void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [window addSubview:viewController. Then.ORG All Rights Reserved .h" #import "Hello_WorldViewController. we make these objects properties.view]. @synthesize viewController. The key words “nonatomic” and “retain” decides the way the object is stored and accessed.(void)dealloc { [viewController release].

This is required for the compiler to relate the objects to the corresponding class. The method “ applicationDidFinishLaunching” is created automatically the SDK.view. Third Code Example Snippet ViewController. Please note we will have to synthesize any properties before using them.h” files.h #import <UIKit/UIKit.m file is the implementation file. We then find a method which is first called as soon as the application starts. We then synthesize the two properties we created earlier. We start by importing the “.h> @interface Hello_WorldViewController : UIViewController { } @end Explanantion of the code above Currently this class has very few lines and it just declares itself as an interface. As our view is being handled by the object viewController the system added addSubview:viewController. It then adds the view on top of the window with the key word “addSubview”.ORG All Rights Reserved . The next method dealloc is to free the memory occupied by the objects we created.Explanantion of the code above We know that . Copyright © 2009 – 2010 EDUmobile. This starts the application with the root window.

We will now take this program to the next level adding an interface to our application and we will do it by using Interface Builder. etc that aren't in use.g.(void)viewDidUnload { // Release any retained subviews of the main view. images.(void)dealloc { [super dealloc]. } .m #import "Hello_WorldViewController. [super didReceiveMemoryWarning].myOutlet = nil.h" @implementation Hello_WorldViewController ////Some methods .Fourth Code Example ViewController. // e. The methods that are there are empty and does not serve any purpose as of now. } @end Explanantion of the code above … Currently the code is not doing much except for being an empty implementation file.ORG All Rights Reserved .(void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. Copyright © 2009 – 2010 EDUmobile. // Release any cached data. } . self.

Though it is possible to add interfaces without using Interface builder by directly using the objective C code. The “Interface Builder” This is the interface creating utility that comes with Xcode for developing interfaces. To see it in action.xib file. Also. You will see the following on your screen… Copyright © 2009 – 2010 EDUmobile. Once you double click on the nib file it will automatically open the interface builder.and so we will create our interface with interface builder. The xib file is an interface file which is called a “nib file”.ORG All Rights Reserved . in your side bar click the resources folder and click on the ViewController. the aim of this article is to make you familiar with IB . but it greatly simplifies the development process and reduces the time to a greater extent.

The File owner is the master class and the interface we creates belong to the File Owner. Component Window This shows the components of the interface.ORG All Rights Reserved . Copyright © 2009 – 2010 EDUmobile. explained in a nutshell… At this point of time you can consider these element as components by which the interface is created and rendered on a device. In our example we have… The File’s Owner. We will deal with them in detail in our later sections. The View is the actual interface that will be visible to the user. First Responder and View. The First Responder is responsible of responding to user inputs done at the interface. namely - 1.The Interface builder has three main parts.

Copyright © 2009 – 2010 EDUmobile. TextBox and even view controllers. Library The library is the collection of interface elements like Label.2.ORG All Rights Reserved . You can create great applications just by using these standard components.

3. select the Inspector from the Drop down menu and the window will appear in your screen. Inspector The inspector is the other major component of the interface builder. If you want to have a look at these attributes. Using the Inspector we can change the following attributes View Attribute Connection Attribute Size attribute Identity attribute. Copyright © 2009 – 2010 EDUmobile.ORG All Rights Reserved . It allows the developer to change various attributes of the interface object.

select View and the Inspector window will show different attributes for each tab as listed above.ORG All Rights Reserved .Then. We will first complete our application which will print “Hello World” on the window. Go to the element label and drag it to the view window which is currently gray in color. Completing the Application Open the library from the Xcode menu. you can clearly see the word “Label” written on the view. We will learn to use this a little later.. Once your label is present on the view. Copyright © 2009 – 2010 EDUmobile. You will see the following ..

that is first tab itself. Save the nib file and close the nib file by closing the component window. And… that is done very easily! Simply double click on label and you can edit it to whatever you want. was it ? Copyright © 2009 – 2010 EDUmobile. just as shown in the figure below… Wasn’t that hard. now that we are done. Alternatively you can select the label and open up the Inspector. we want to execute the first program we wrote! In your Xcode top bar. So. you will see the emulator appear and display the text… “Hello World” on the screen.Moving forward.ORG All Rights Reserved . click “Build and Run” and if everything is proper. our task is to now convert this label to “Hello World”. change the text from label to Hello World. In view attribute.

and we should be able to change the message. as per the click. We now move on to the Interface builder.h> @interface Hello_WorldViewController : UIViewController { IBOutlet UILabel *label. We will start by creating an IBOutlet for the label which we want to change and an IBAction to interpret the user action.h #import <UIKit/UIKit. to create the necessary interface. we will have to augment the code created by Xcode.Lets Move on to our Next Exercise As we have now successfully created our first Application we will try to extend this application and will try and add a user event to it. Copyright © 2009 – 2010 EDUmobile.ORG All Rights Reserved . -(IBAction)buttonPressed. Make the following changes to Hello_WorldViewController. We then make this object a property to automatically use getter and setter functions later. We then create a -(IBAction) buttonPressed trigger which will be called when user presses the button element on the screen. To do this. @end The code above creates an Outlet of class UILabel to store the label object which has been defined as *label. retain) IBOutlet UILabel *label. What we want to do is to insert a button in the interface which can be clicked by the user. } @property (nonatomic.

we will associate this label with our UILabel object.Double click the view controller nib file to open the interface builder. “label” was the object we created in our code. Now. Control drag from the File Owner to the Label which is now written as “Hello World” and from the pop up that appears select “label”.ORG All Rights Reserved . Copyright © 2009 – 2010 EDUmobile. Open the library and drag a round rectangle button from the library to get the following view… Click on the button and change the name to switch.

Refer to the two images below - Copyright © 2009 – 2010 EDUmobile.ORG All Rights Reserved .

Once our IBOutlet for label is set we will move to add the IBAction to button. Go to the connection attributes and drag “Touch up inside” to the File Owner. If the connection is successfully joined your Connection Inspector should look like the following… Copyright © 2009 – 2010 EDUmobile. To connect the IBAction we will select the button and open up the Inspector. Select the action “buttonPressed” from the pop up.ORG All Rights Reserved .

} .h" @implementation Hello_WorldViewController @synthesize label. Copyright © 2009 – 2010 EDUmobile.myOutlet = nil.text isEqualToString:@"World Hello"]) label. [super didReceiveMemoryWarning]. -(IBAction)buttonPressed{ if([label.m file and add the following code… #import "Hello_WorldViewController. In the IBAction method we apply a simple conditional to check the current string and then change the string based on the current stage. [super dealloc].text = @"World Hello". images.ORG All Rights Reserved . } .g. } .text = @"Hello World".Once this is done save your nib file and move on to the Xcode. // e.(void)viewDidUnload { // Release any retained subviews of the main view. else label. This completes our Application which displays hello world and then changes itself based on the user command.(void)dealloc { [label release]. Now. } @end We start by synthesizing the label object.(void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. etc that aren't in use. self. open the Hello_WorldViewController. // Release any cached data.

ORG All Rights Reserved .The output should look like this … Copyright © 2009 – 2010 EDUmobile.

ORG All Rights Reserved .org/downloads/Sample.This concludes our introductory tutorial for iPhone Programming! We hope you enjoyed it! You may download the source code for the above project from the following link .zip Copyright © 2009 – 2010 EDUmobile.http://edumobile.

With the iPad the user can be comfortable with both the vertical or horizontal (landscape) orientation. This means that your iPad App has to support both orientations – that is. or a full-screen viewing of the details view with the list available in a popover view – when in portrait orientation. can now take advantage of the new detailed view controller. View Controller All iPhone Apps which currently use UINavigator to switch to another view showing details of something selected in a list. The iPad went on sale in April 2010 in the market. it must be able to rotate and appear properly in both views. then you are potentially losing out. and Apple created a new section in iTunes that lists new iPad Apps or enhanced iPhone Apps that are compatible with iPad. you should definitely make your iPhone App compatible with iPad also. iPad development is an extension of iPhone development and you must first learn iPhone programming. Some of the ways the iPad differs from the iPhone are… Rotation Orientation Support – Supporting rotation is a must on the iPad. which is normally held vertically (portrait view). Using the new SDK you will be able to create a single binary which will install one version of your app when used on the iPhone or iPod Touch and a different binary when installed on an iPad. All iPad users who have already downloaded your free or paid App to their iPhone or iPod Touch will be able to download your iPhone App – only if you have updated your binary submission to the App store to make your iPhone App compatible with iPad. You should use the UIKit functionality to build this into your App.Bonus Chapter on iPad Development Jumping from iPhone to iPad Development You must take advantage of the iPad launch and the benefits you can gain from it. Copyright © 2009 – 2010 EDUmobile. This is because the iPad does not have a normal way in which it will be held unlike the iPhone.ORG All Rights Reserved . before you move on to learning the new extended functions and features specially made for the iPad. All of the Apps will have to been rewritten to use these new features and users will expect them of your applications as well. If you do not update and create the separate binaries. For this. This functionality will now provide simultaneous viewing of the list and the detailed view – when in landscape orientation.

will automatically convert the master list to a popover menu when the iPad is placed in the Landscape orientation. Hence. Tabs Tabs can appear on the top or at the bottom of the screen on the iPad. This gives you the ability to provide more traditional tabs on the top of the UX rather than just at the bottom. you will need to create and use a custom view for them – should you use Popovers in your iPad App. Hence. Design cleverly to see where you can replace entire views with Popovers. a whole new set of gestures are possible. while designing. The iPad screen is hence large enough to allow different simultaneous gestures Copyright © 2009 – 2010 EDUmobile. and menus in the iPad. or creating D-pad controls. This will greatly simplify your apps on the iPad and the speed and ease with which users can navigate quickly. With the iPad and its bigger screen. make sure you leave some areas on the sides where the user can touch the screen to dismiss the popover window. Also. Don note that since the iPhone and iPad Touch do not support Popovers. For example 2 people can play a game of hockey-puck with each other. since the iPad screen is large. You can see Steve Jobs doing this in the Developer Keynote Speech. Apple has built in a functionality that supports multiple users touching different parts of the screen at the same time.Popover Views – Popover views are not supported in the iPhone. These popover views can easily be closed by the user by tapping on any region outside the popover window boundary. TableView TableView controls can now have multiple columns.ORG All Rights Reserved . An example would be the color picker shown in the Brushes App. You can thus also put tabs in the top of your Popover views. Therefore. modeless dialogs. More Finger Gestures The limited screen size of the iPhone and iPad resulted in limitations in the possible touch screen finger gestures. all Apps which use the master/detail view. try to eliminate custom controls or provide an enhanced UX to your users. but can be used to create modal dialogs. such as shown in Pages and modeless dialogs. You can use this same popover technology to create menus. There is plenty of space for long-touch and also drag gestures and multi-finger controls ( the 3-finger twist gesture ).

You can define if you want to auto-enable or disable this functionality. While developing you should make sure to check for compatibility so that you can enable or disable the feature. This will allow you to generate reports in PDF should you App require this. you do not have to display the video across the entire screen. This functionality can be used to combine the user experience with multiple multimedia functionality. This means you can easily share data files between your devices if required by the App. Multimedia If you create video content areas. Text Input and Keyboards – Each text input field (using the TextView function). for TextView controls as needed. The iPad has an optional “video out cable” – that you can use to project the screen in full or part.ORG All Rights Reserved . The iPad also supports wireless headsets and microphone. as appropriate. and you can restrict video to only a small portion or area of the screen. Compass and Location The Compass and Location / GPS functionality is only available in the higher models of the iPad that support 3G. I. address keys etc. This is fantastic for making different parts of the screen so that each user can have their own virtual control surface area. The iPad supports mounting a shared file directory by connecting the iPad via USB to a PC or Mac. Bluetooth connected keyboards are supported out-of-the-box.P. thus allowing total hands-free voice-driven control of Apps. No need to configure anything. will support spell checking and auto-completion by default – just as in the iPhone. thereby displaying different types of custom keyboard inputs like Scientific keys. You can also implement multiple custom virtual keyboard layouts within a single App. Many users will probably selectively connect third party Copyright © 2009 – 2010 EDUmobile. Using CoreGraphics. all Apps will now be able to generate PDF content.

this slight disparity in proportions will cause your view to stretch unevenly if you display it in full screen on the iPad.2″ . There have so many way to display the HelloWorld in the iPad. but i’ll show you “HelloWorld” example using Interface Builder and writing little code. if required for the iPad. At the tall end the screen is 2. At the short end the size is 2.2 . i am going to run this application in the iPad. So let see how it will be worked. required “iPhone SDK 3.ORG All Rights Reserved . Copyright © 2009 – 2010 EDUmobile. in order to avoid any uneven full screen resizing.13x the size of the iPhone or iPod Touch. Step 1: Open the Xcode and create a new Xcode project usingView base application template. Execute Hello World Program on the iPad This is the “HelloWorld” example. so first install the iPhoneSDK 3.keyboards to their iPad. These proportions are not the same as with the iPhone or iPod Touch – and differ slightly. Screen Size Disparity Avoid undesirable uneven image stretching of your App when users change the orientation of the iPad. You will therefore need to customize this view. Therefore. Give the application name “Button Fun iPad”.This is the very simple application.4x the size of the iPhone or iPod Touch. For the iPad application . Your App can be developed to support such alternate text-input capability. The iPad is 1024 pixels in the tallest dimension and 768 pixels in the shortest dimension.

#import <UIKit/UIKit.xib file open it to the Interface Builder.h. a) Open the View window. first drag the label from the library and place it to the view window and select the label and bring up Attribute Inspector and delete the text. we have added UILabel for display the text and added IBAction buttonPressed: so make the following changes in the file.Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. Step 3: xpand classes and notice Interface Builder created the Button_Fun_iPadViewController class for you. Button_Fun_iPadViewController. } @property (retain.h file. Expand Resources and notice the template generated a separate nib. b) Next drag a Round Rect from the library and place it to the view window. Step 5: After changing in the Button_Fun_iPadViewController. You can explore the directory structure to check out the content of the directory. for the “Button Fun iPad”. Step 4: In the Button_Fun_iPadViewController. double click the Round Rect and give the name “ClickMe”. c) Now connect the File’s Owner icon to the View icon and select view.h> @interface Button_Fun_iPadViewController : UIViewController { IBOutlet UILabel *statusText. . double click the Button_Fun_iPadViewController.xib. -(IBAction)buttonPressed:(id)sender. nonatomic) UILabel *statusText.

Now save the Button_Fun_iPadViewController. [newText release]. statusText.text = newText. close it and go back to the Xcode. } Step 7: Now compile and run the application in the Simulator. Step 6: Open the Button_Fun_iPadViewController.d) Connect File’s Owner icon to label and select ”statusText”.xib file.Drag from the TouchUpInside to the File’s Owner icon and select buttonPressed: action.ORG All Rights Reserved .m file and make the following changes in the file: -(IBAction)buttonPressed:(id)sender { NSString *newText = [[NSString alloc] initWithFormat: @" Hello World!!!"]. e) Select the Round Rect from the view window and bring up connection Inspector. You can download the SourceCode from here Button Fun iPad Copyright © 2009 – 2010 EDUmobile.

along with material and Weekly Worksheets. You will also get access to our private forum where you can meet other fellow iPhone developers. What Next ? This was a small step in our journey towards getting started with iPhone development. If you are interested in learning iPhone and iPad Development. It comes with a full money back guarantee. The course is delivered over a period of 12 weeks via Online Video that you may download and view at your convenience. so there is no risk at all..So.ORG All Rights Reserved . Click Here To Learn More About The iPhone Course and To Enroll Affiliates Join Our High Paying Affiliate Program and Make Tons Of Money! Interested in promoting our Courses and making money? Get instant $25 bonus for signing up! Click Here to sign up for our Affiliate Program Copyright © 2009 – 2010 EDUmobile. we suggest you sign up for our complete 12 Week iPhone Programming Course at the link below. You will be assigned your own personal one-on-one tutor.. whom you may consult any time with questions and problems you face.

Sign up to vote on this title
UsefulNot useful