The Best Resources In iOS Development August 3rd 2010 (For Week 07/24-07/30)

Welcome to another weekly summary.  I’m a bit late with this one as I was finishing up the Beginners iPhone Action Game Tutorial.  If you are looking for an extensive tutorial on creating an iPhone or iPad game I highly suggest you check it out.

Things have gotten a little bit slower with the number of quality resources for iOS developers appearing each week.  I’m guessing it has something to do with the weather.

That being said here are some good ones:

Blocks – An Interesting Objective-C Addition In iOS 4
A good tutorial on how to use C closures that have been added to the iOS sdk.

Great Beginner iPhone And iPad Dev Screencasts
Some good absolute beginner screencasts.  If you are totally new to programming and having trouble you will want to check these out.

Easy Open Source iPhone And iPad Library For Communicating With Web Services
A new library that makes it easier to obtain and parse data from web services.

Easy iPhone Simulator Screenshots With Status Bar Removed
An automatic image cropper to simplify iPhone app image taking.

How To Push Out Notifications Locally Based On Time
A tutorial on the new local timer based push notifications recently added to the iOS sdk.

That’s it, if you find something you like please share it!

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

Hosting A Beta Test For Your iPhone and iPad Apps

Hosting a beta test for an iPhone or iPad app is often a bit much.  The time spent conducting such a test can be extremely costly.

If you are creating a more advanced app though it can be a necessity, and there are many things you will need to do such as: finding beta testers, sending out ad-hoc builds, guiding people through the install process, and filtering through the different responses.

Ray Wenderlich has written a great article that explores all of these facets and more in detail which you can find here:
How To Host A Beta Test For Your iOS App

Thanks for reading, if you lik this please share it!

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

Custom iPad UISplitViewController Adds Many Slick Features – Open Source

The UI libraries in the iPhone and iPad sdk are excellent, and it’s rare to find a library that adds many significant features.  I recently came across one such library.

The library I’ve come across enhances the UISplitViewController on the iPad adding great features such as the ability to reposition the master and detail views, change the position of the split so you can resize the views, toggle visibility of the master view, and much more.

Here is a demo video of the enhanced UISplitViewController:

The library is known as MGSplitViewController from Matt Gemmell and can be found on Github here:
MGSplitViewController On Github

You can find the original writeup on it here:
MGSplitViewController For iPad

Thanks for reading, if you like this please share it!

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

How To Use Visio As A Level Editor

Laying out levels can be a pain, in fact it can be downright impossible if you don’t have some sort of editor.

I caught this very simple guide on to how to do this using Visio which is very interesting as it is a tool that so many people have.

Here’s the process in a nutshell, export the Visio document convert it to an .xsl file then convert that into a .plist file using a specific XML template and read the contents in using multiple NSDictionary’s.

I’m making the process sound simplistic, but there really isn’t much more to it than that, you will of course need to do your own coding to make sure your game knows how to handle the extracted data :)

You can find more info about this process along with the tools used over at Funky Visions:
Using Visio To Write iPhone Apps. Seriously?

If you liked this, please share it!

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

Good Explanation Of Instruments In Xcode

Apple has created some great tools to help you debug and optimize your iPhone and iPad apps.

However, knowing exactly what they do can be a challenge.  I’m still figuring everything out and finding new uses for the tools.  I suspect that unless you have been working on Mac software development for a long time then you probably feel the same.  With the addition of multitasking this has gained even greater importance as apps now require further optimization.

I found this nice little rundown of all the latest tools available with Xcode.

The rundown can be found here:
Apple’s Instruments for Developers

If you’re new to Xcode, or you just don’t feel your getting the most out of Instruments in Xcode then I suggest checking it out.

If you like this, please share it!

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

Interesting Info About iAds For Developers

So far iAds have provided a very high CPM rate although some have complained about the fill rates.  Recently Apple announced their iAds for developers program.

Here’s some of the more interesting info about it:

  • The cost is 0.25 cents per click, radically lower than the high cost per click paid for brand advertising.
  • One developer stated they had a conversion rate of 20%
  • Competitors apps can be excluded
  • You can’t choose to display specific ads in your app

Overall with the conversion rate and pricing it looks like things are looking extremely good for the new iAds for developers feature.

If you liked this info, please share it!

[Source: Business Insider]

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

Handling Z-Ordering In Cocos2D Map Based Games

If you’ve used Cocos2D for awhile you may have had some difficult when trying to handle the display order of images.

Things get even more complicated if you are creating an isometric game.  The player character may need to be placed behind an obstacle such as a rock or a tree.  In v0.99.1 automatic z-ordering for tile maps was implemented, and the problem was somewhat solved, but some problems still exist and there is some tweaking to be done.

Another problem, especially with map-based games is creating a player HUD display as the images need to be placed at the right z-ordering and at a consistent location on the screen.

Nat Weiss has created a tutorial on how to overcome these problems by creating two different custom sprite classes which can be found here:
CCZSprite and HudLevelSprite

These two classes should be of help to anyone interested in creating a map-based game in Cocos2D.

Thanks for reading, if you like this please share it!

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

Distimo Mobile Report – July 2010

This report covers the Apple App Store for iPad and iPhone (with specific focus on in-app purchases), as well as BlackBerry App World (Worldwide), Google Android Market, Nokia Ovi Store, Palm App Catalog and Windows Marketplace for Mobile for June 2010 in the United States. The major findings are:

* The percentage of applications with in-app purchases is significantly higher in the Apple App Store for iPad (10%) than in the Apple App Store for iPhone (2%). The Games and Social Networking categories in both stores have the highest proportion of applications with in-app purchases available.

* The most successful free applications that monetized using in-app purchases this month in the Apple App Store for iPhone are MobiTV (MobiTV), ESPN 2010 FIFA World Cup (ESPN) and Tap Fish (BayView Labs).

* The most successful paid applications that monetized using in-app purchases this month in the Apple App Store for iPhone are Guitar Hero (Activision Publishing, Inc.), TomTom U.S.A. (TomTom International BV) and Call of Duty: World at War: Zombies II (Activision Publishing, Inc.).

* Mirroring the Distimo report covering May 2010, Pages and iBooks, published by Apple Inc, are again the number one paid and free applications on the Apple App Store for iPad, respectively.

* Three out of the ten most popular applications in the Apple App Store for iPhone were published by Electronic Arts.

* Quickoffice Connect Mobile Suite for iPad entered the top 10 highest ranked paid applications chart in the 6th position. It was the top grossing application in the Apple App Store for iPad after Pages by Apple Inc.

* Nine out of the ten most popular paid applications on the Apple App Store for iPhone are Games, however only two out of the ten most popular free applications are Games. In the Nokia Ovi Store, seven out of ten of the most popular paid applications are Games, while only three out of ten of the most popular free applications are Games.

You can download the report here.

Change View in iPad

In this application we will see how to change view in iPad.

Step 1: Create a Window base application using template. Give the application name “Windowbase_iPad”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: xpand classes and notice Interface Builder created the Windowbase_iPadAppDelegate class for you. Expand Resources and notice the template generated a separate nib, MainWindow.xib, for the “Windowbase_iPad”.

Step 4: We need to add two images in the resource folder. Give the name of the resources “1-1.png”,”2-1.png”.

Step 5: We have added QuartzCore.framework, select Frameworks -> add -> Existing frameworks -> selectQuartzCore.framework.

Step 6: In the Windowbase_iPadAppDelegate.h file, we have added instances of UIView and UIImageView class, and create one IBAction method. So make the following changes in the file.

#import <UIKit/UIKit.h>

@interface Windowbase_iPadAppDelegate : NSObject <UIApplicationDelegate> {
   
        UIWindow *window;
        UIView  *subView;
        UIImageView *view1;
        UIImageView *view2;
        BOOL change;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UIView  *subView;

(IBAction)ChangeView:(id)sender;

Step 7: Double click your MainWindow.xib file open it to the Interface Builder. Open the the window and drag view from the library and place it to the window. Next drag Toolbar from the library and place it buttom of the view window. Now select ViewChangeAppDelegate, and bring up connection inspector. Select from subView to the view, and ChangeView to the BarButtonItem. Now save your .xib file and go back to the Xcode.

Step 8: Open the Windowbase_iPadAppDelegate.m file and make the following changes in the file.

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
       
        UIImage *image1 = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"1-1.png" ofType:nil]];
        view1 = [[UIImageView alloc] initWithImage:image1];
        UIImage *image2 = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"2-1.png" ofType:nil]];
        view2 = [[UIImageView alloc] initWithImage:image2];
        view2.hidden = YES;
        [subView addSubview:view1];
        [subView addSubview:view2];
        change = NO;
       
        [window makeKeyAndVisible];
       
        return YES;
}

(void)performTransition
{
       
        CATransition *transition = [CATransition animation];

        transition.duration = 0.75;
        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
       
        NSString *types[4] = {kCATransitionMoveIn, kCATransitionPush, kCATransitionReveal, kCATransitionFade};
        NSString *subtypes[4] = {kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom};
        int rnd = random() % 4;
        transition.type = types[rnd];
        if(rnd < 3)     {
                transition.subtype = subtypes[random() % 4];
        }
       
        change = YES;
        transition.delegate = self;
       
        [subView.layer addAnimation:transition forKey:nil];
       
        view1.hidden = YES;
        view2.hidden = NO;
       
        UIImageView *tmp = view2;
        view2 = view1;
        view1 = tmp;
}

(void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{
        change = NO;
}

(IBAction)ChangeView:(id)sender
{
        if(!change)
        {
                [self performTransition];
        }
}

Step 9: Now compile and run the application in the Simulator.

You can Download SourceCode from here Windowbase_iPad

Make $400 to $5000 DAILY from Ad Revenues With Your Free App

The iPhone Apps get-rich-quick landscape is best suited for one of two people development shops. However, some companies are also making good revenues – specifically from in-app advertising.

In the report below, AdWhirl says that top apps can make $400 to $5,000 per day on ads. The average CPM works out to around $2 per 1000 impressions. It may not look  impressive but its substantially better than the CPM rates at Facebook or MySpace apps.

However – These apps are from the most popular section on the app store… listing within the top 100 free apps. This is what is causing a problem for small developers. You need to crack into the top 100 if you want to get to the $400 daily revenue target.



Adwhirl iPhone Advertising Snapshot



You can access the Adwhirl data report directly here.

Display Splash Screen in iPad

In this application we will see how to display Splash Screen in iPad.

Step 1: Create a View base application using template. Give the application name “DisplaySplash_iPad”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Expand classes and notice Interface Builder created the DisplaySplash_iPadViewController class for you. Expand Resources and notice the template generated a separate nib, DisplaySplash_iPadViewController.xib, for the “DisplaySplash_iPad”.

Step 4: We need to add one resource in the resource folder for display splash.

Step 5: In the DisplaySplash_iPad.h file, we have created instance of UIView class and two methods. So make the following changes in the file.

#import <UIKit/UIKit.h>

@interface DisplaySplash_iPadViewController : UIViewController {

        IBOutlet UIView *displaySplashScreen;
       
}

(void)displayScreen;
(void)removeScreen;

Step 6: Double click the DisplaySplash_iPadViewController.xib file and open it to the Interface Builder. Drag the view from the library and place it to the Main Window. Open the second view icon from the MainWindow,drag the image view from the library and place it to the view window,select the view and bring up Attribute Inspector select the image “themes.png”. Select the File’s Owner icon from the MainWindow and bring up Connection Inspector, drag from the displayScreen to the last view icon and connect File’s Owner icon to the view. Now save it , close it and go back to the Xcode.

Step 7: Open the DisplaySplash_iPad.m file and make the following changes in the file.

(void)displayScreen
{
       
        UIViewController *displayViewController=[[UIViewController alloc] init];
        displayViewController.view = displaySplashScreen;
        [self presentModalViewController:displayViewController animated:NO];
    [self performSelector:@selector(removeScreen) withObject:nil afterDelay:6.0];
       
       
}

(void)removeScreen
{
        [[self modalViewController] dismissModalViewControllerAnimated:YES];
}

Step 8 : Now compile and run the application in the Simulator.

You can Download SourceCode from here DisplaySplash_iPad

CNBC Feature – Planet of the Apps

Planet of the Apps: A Hand-held Revolution Premiered on January 7th 10pm ET on CNBC. In this program CNBC looked at at how apps have changed our lives, and they meet some of the creators behind them, and figure out just how big a business they really are. For those who missed the CNBC special feature on iPhone Apps, this is 45 minute show is a must see / download. Just search on Youtube for related clippings or if you know where on torrents you can probably download the full episode from – if in USA from Hulu, picrap.com, clicker.com or any TV show streaming site. For more information. Please log onto: www.planetoftheapps.cnbc.com

Click here to view the embedded video.

Music Play in iPhoneOS4

This is the very simple example . In this application we will see how to play music in iPhone oS4.

Step 1: Create a new project in Xcode using View base application. Give the application name “MusicPlay_OS4”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: xpand classes and notice Interface Builder created the MusicPlay_OS4ViewController class for you. Expand Resources and notice the template generated a separate nib, MusicPlay_OS4ViewController.xib, for the “MusicPlay_OS4”.

Step 4: We need to add sound files in the Resources folder. Give the name of the sound files “music.mp3”,”sound.aif”. And also add a backgroung image.

Step 5: We need to add also two frameworks.So select Frameworks -> Add -> Existing Framework -> then select AVFoundation.framework and AudioToolbox.framework.

Step 6: In the MusicPlay_OS4ViewController.h file, we have  importAVFoundation.framework and AudioToolbox.framework. Create a instance of  AVAudioPlayer and UIButton class and create two IBAction method. So make the following changes in the file.

#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>

@interface MusicPlay_OS4ViewController : UIViewController
<AVAudioPlayerDelegate>{
       
        SystemSoundID systemSoundID;
        AVAudioPlayer *player;
        UIButton *StartStopSound;
       
}

@property (nonatomic, retain) IBOutlet AVAudioPlayer *player;
@property (nonatomic, retain) IBOutlet UIButton *StartStopSound;

(IBAction) playSound: (id) sender;
(IBAction) playSong: (id) sender;

Step 7: Double click the MusicPlay_OS4ViewController.xib file and open it to the Interface Builder. First drag the Image View from the library and place it to the View window. Select the image view and bring up Attribute Inspector, select the background image. Drag two Round Rect button from the library and place it to the view window.Give the name of the button “Play Sound “and “Play Song” Connect File’s Owner icon to the View icon and select View. Drag File’s Owner icon to the Play Song button and select StartStopSound. Select the Play Sound button and bring up Connection Inspector and drag from the Touch Up Inside to the File’s Owner icon, select playSound: action. Do the same thing with PlaySong button and select the playSong: action. Now save the MusicPlay_OS4ViewController.xib file, close it and go back to the Xcode.

Step 8: Open the MusicPlay_OS4ViewController.m file and make the following changes in the file.

(void)viewDidLoad {
        NSLog(@"InView did load");
        AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle]
                                                                                                                                           pathForResource: @"sound" ofType:@"aif"]],
                                                                         &systemSoundID);
   
       
        player = [[AVAudioPlayer alloc]
                          initWithContentsOfURL:[NSURL fileURLWithPath:
                                                                         [[NSBundle mainBundle] pathForResource:@"music" ofType:@"mp3"]]
                          error:nil];
       
       
        [player prepareToPlay];
       
       
       
}

(IBAction) playSound:(id) sender {
       
        NSLog(@"In Sample");
        AudioServicesPlaySystemSound(systemSoundID);
}

(IBAction) playSong:(id) sender {
       
        if ([[NSString stringWithFormat:@"%@", [StartStopSound titleForState:UIControlStateNormal]] isEqualToString:@"Play Song"]) {   
                [player play]
                [StartStopSound setTitle:@"Stop Song" forState:UIControlStateNormal];   }
        else { 
                [player stop]
                [StartStopSound setTitle:@"Play Song" forState:UIControlStateNormal];  
        }      
}

Step 9: Now compile and run the application in the Simulator.

You can Download Source Code from here MusicPlay_OS4

MapKit example in iPhone

In this application we will see how to map display and how to point out any location using latitude and longitude.

Step 1: Create a View base application using template. Give the application name “MapKitDisplay”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Xpand classes and notice Interface Builder created the MapKitDisplayViewController class for you. Expand Resources and notice the template generated a separate nib, MapKitDisplay ViewController.xib, for the “ MapKitDisplay”.

Step 4: We need to add NSObject class in the project. Select Classes -> Add -> New File -> Cocoa Touch Class -> Objective C class -> select NSObject from the Subclass of. Give the file name “DisplayMap”.

Step 5: We have added two framework in the project. Select Frameworks -> Add -> Existing Frameworks -> Add CoreLocation.framework and MapKit.framework.

Step 6: In the MapKitDisplayViewController.h file, we have import MapKit framework, and define MKMapViewDelegate protocol in the file, also add Outlet with a pointer to the MkMapView class. So make the following changes in the file.

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@class DisplayMap;

@interface MapKitDisplayViewController : UIViewController <MKMapViewDelegate> {
       
        IBOutlet MKMapView *mapView;
}
@property (nonatomic, retain) IBOutlet MKMapView *mapView;

Step 7: Double click the MapKitDisplayViewController.xib file and open it to the Interface Builder. First drag the MapView from the library and place it to the view window. Connect File’s Owner icon to the View icon and select view. Connect File’s Owner icon to the MKMapView and select mapView. Now save the MapKitDisplayViewController.xib file, close it and go back to the Xcode.

Step 8: Open the MapKitDisplayViewController.m file and make the following changes in the file:

(void)viewDidLoad {
    [super viewDidLoad];
       
        [mapView setMapType:MKMapTypeStandard];
        [mapView setZoomEnabled:YES];
        [mapView setScrollEnabled:YES];
        MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
        region.center.latitude = 22.569722 ;
        region.center.longitude = 88.369722;
        region.span.longitudeDelta = 0.01f;
        region.span.latitudeDelta = 0.01f;
        [mapView setRegion:region animated:YES];
       
        [mapView setDelegate:self];
       
        DisplayMap *ann = [[DisplayMap alloc] init];
        ann.title = @" Kolkata";
        ann.subtitle = @"Mahatma Gandhi Road";
        ann.coordinate = region.center;
        [mapView addAnnotation:ann];
}

(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:
 (id <MKAnnotation>)annotation {
        MKPinAnnotationView *pinView = nil;
        if(annotation != mapView.userLocation)
        {
                static NSString *defaultPinID = @"com.invasivecode.pin";
                pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
                if ( pinView == nil ) pinView = [[[MKPinAnnotationView alloc]
                                                                                  initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];

                pinView.pinColor = MKPinAnnotationColorRed;
                pinView.canShowCallout = YES;
                pinView.animatesDrop = YES;
                }
        else {
                [mapView.userLocation setTitle:@"I am here"];
        }
        return pinView;
}

We define here first, coordinate regions to zeros, Then we enter coordinates of our place that, Kolkata (Mahatma Gandhi Road), define the latitude and longitude of this place. We create an instantiate of DisplayView object and add it to our map. To do this, we add the delegate function that will display the annotations on to our map. We start by having DisplayView name a pointer we’ll call “ann.”

Step 8: In the DisplayView.h file , we have import and set CLLocation class reference to incorporate the geographical coordinates and altitude of our device. So make the following changes in the file.

#import <Foundation/Foundation.h>
#import <MapKit/MKAnnotation.h>

@interface DisplayMap : NSObject <MKAnnotation> {

        CLLocationCoordinate2D coordinate;
        NSString *title;
        NSString *subtitle;
}
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;

Step 9: Open the DisplayView.m file and make the following changes in the file:

#import "DisplayMap.h"

@implementation DisplayMap

@synthesize coordinate,title,subtitle;

(void)dealloc{
        [title release];
        [super dealloc];
}

Step 10: Now compile and run the application on the simulator.

You can Download SourceCode from here MapKitDisplay

How to play Video in iPad

This is the very simple application . In this application we will see how to play video in the iPad.

Step 1: Create a View base application using template. Give the application name “VideoPlay_iPad”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Xpand classes and notice Interface Builder created the VideoPlay_iPadViewController class for you. Expand Resources and notice the template generated a separate nib,VideoPlay_iPadViewController.xib, for the “VideoPlay_iPad”.

Step 4: We need to add MediaPlayer.framework in the Frameworks folder. Select-> Frameworks folder -> Add ->Existing Frameworks -> then select MediaPlayer.framework.

Step 5: In the VideoPlay_iPadViewController.h file, we have created instance of MPMoviePlayerController class, that manage the playback of a movie from a file or from the network, and create a instance of NSURL class . So make the following changes in the file.

#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>

@interface VideoPlay_iPadViewController : UIViewController {

        MPMoviePlayerController *videoPlayer;
        NSURL *videoURL;
       
}

Step 6: Open the VideoPlay_iPadViewController.m file and make the following changes in the file.

(void)viewWillAppear:(BOOL)animated
{
        NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"3idiots.mov" ofType:nil];
        NSURL *url = [NSURL fileURLWithPath:urlStr];
        videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
        [self.view addSubview:videoPlayer.view];
        videoPlayer.view.frame = CGRectMake(0, 0,768, 1000);  
        [videoPlayer play];
}

Step 7: Now compile and run the application in the Simulator.

You can Download SourceCode from here VideoPlay_iPad