Developing applications for the iPad


If you’ve not been living in a cave with Osama Bin Laden for the past six months you’d be aware that Apples new creation the “iPad” is out & selling like hot cakes. As soon as the iPad was announced Apple worshipers started flocking to Apple Stores worldwide lining up to get their hands onto the Steve Jobs latest revelation. It’s not new for Steve Jobs to carve out a niche for his products and stun the aesthetes and geeks alike. Steve Jobs is a visionary who has transcended computing to the heights unimaginable before. iPod, iPhone & iPad are not just bare computing devices anymore they’ve become a part of our contemporary culture.

According to http://www.geek.com Apple has sold more than 3 million iPads since its launch at a flashing rate of almost one iPad every other second and industry experts say the trend is most likely to continue. This 3 million plus & growing consumer base represents a very handsome opportunity for the developers to tap into.

If you’ve been developing for the iPhone/iPod touch you’re in luck, iPad uses the same architecture, same operating system, same set of development tools & same application framework. Hence easing the life of developers but still there are a few subtle difference that one needs consider when developing for iPad.

Support for Screen Orientations

First and foremost thing that developers should consider is the support for all screen orientations. This behavior differs slightly from the iPhone, where running in both portrait and landscape modes is not required.

New UI Considerations

iPad changes the way user interacts with your application. iPad have a larger screen real estate & lends itself to a different set of behaviors for navigating information. On the other hand iPhone apps tend to be more navbar style applications where you dig in level by level to access the required information. This type of applications suits iPhone & iPod touch because screen size is very limited. For managing information density and presentation on larger screen two new concepts are introduced in the iPad SDK namely Popover Controller & Split View Controller.

Popover Controller

UIPopoverController is not a UIViewController, instead it is used to host a content view controller, that content view controller has a view that it manages and this content view controller gets the viewWillAppear: viewDidAppear etc delegate calls. UIPopoverController is usually controlled by some other object that can be another view controller or the applications delegate to manage its lifetime.

You create UIPopupViewController by calling

–   (id)initWithContentViewController:(UIViewController *)viewController;

The view controller provided becomes the content view controller for the UIPopoverController.

You present the UIPopoverController using

– (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated;

allowing you to present a popover from a rect in a particular view. “arrowDirections” is a bitfield which specifies what arrow directions are allowed when laying out the popover; for most uses, “UIPopoverArrowDirectionAny” is sufficient. Another convenience method that can be used for presenting UIPopover is

– (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated;

allowing you to present it from a “UIBarButtonItem” instance. “arrowDirection” is limited to UIPopoverArrowDirectionUp/Down only.

To dismiss it you call

– (void)dismissPopoverAnimated:(BOOL)animated;

The delegate methods for “should” and “did” dismiss are not called when the popover is dismissed in this way.

Split View Controller

UISplitViewController is a full screen view element, which is itself a UIViewController sub class. It has a delegate that informs it about the events that happen. Split views are a way to present two custom views side-by-side. They are a good supplement for navigation-based interfaces and other types of master-detail interfaces.

You usually create them in nibs but they can also be created programmatically

UISplitViewController *svc = [[UISplitViewController alloc] init];

There are a couple of delegate methods that you can look up in the UISplitViewController.h header file or the official documentation to get a better understanding.

SplitViewController
SplitViewController

Tabs

Tabs can appear on the top or at the bottom of the screen on the iPad. You can also put tabs in the top of your Popover views.

Modal Presentation

Views that are presented modally now can be configured to cover only a part or the entire window.

Custom Input Views

Now, you can associate an input view with any custom views you create. You are not just limited to the default keyboards provided with the UIKit.

PDF Generation

Starting from iOS3.2 now you can create PDF files in your home directory.

Document Interaction Controller

You can use UIDocumentInteractionController class to preview files, copy their contents to the pasteboard, or pass them to another application for opening. This is feature is also present in iOS4.

New Gesture Recognizers

iPad introduced support for detecting gestures in a uniform manner. Gesture recognizers simplify the interface for detecting swipe, pinch, and rotation gestures, among others. This functionality is also present in iOS4.

Multimedia

If you create video content areas, you do not have to display the video across the entire screen, and you can restrict video to only a small portion or area of the screen. This functionality can be used to combine the user experience with multiple multimedia functionality.

Universal Apps

You can also use XCode to generate universal binaries that run on both the iPhone & iPad check out the official documentation on how to do it. If your code needs to follow a different path depending on the underlying device type, you can use the userInterfaceIdiom property of UIDevice to determine which path to take. Something like this

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

{

// The device is an iPad running iPhone 3.2 or later.

//create PopoverViewController etc… iPad specific.

}

else

{

// The device is an iPhone or iPod touch.

// Create Navigation Bar etc… iPhone specific

}

Advertisements