Hello World with Navigation Base application in iPhone

This is the very simple example. In this example we will see how to Hello iPhone display using navigation base application.

Step 1: Create a Navigation Base application using template. Give the application name “HelloWorld_NavigationBase”.

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 RootViewController class for you (See the figure below). Expand Resources and notice the template generated a separate nib,RootViewController.xib, for the “HelloWorld_NavigationBase”.

Step 4: Open the RootViewController.m file, for this example we need to add only two lines of code in this file . So make the changes.

(void)viewDidLoad {
    [super viewDidLoad];

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
     self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

  (UITableViewCell *)tableView:(UITableView *)tableView   cellForRowAtIndexPath:(NSIndexPath *)indexPath {

   static NSString *CellIdentifier = @"Cell";

   UITableViewCell *cell = [tableView  dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell == nil) {
   cell = [[[UITableViewCell alloc]   initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]    autorelease];
}

  // Configure the cell. // added below two line
    [[cell textLabel] setTextAlignment:UITextAlignmentCenter];
    [cell.textLabel setText:@"Hello iPhone!"];

   return cell;
}

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

You can Download SourceCode from here HelloWorld_NavigationBase

ViewBase application in iPad

This is the simple View Base application. In this application we will display image,  button and label.

Step 1: Create a View base application using template. Give the application name “ViewBase_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 ViewBase_iPadViewController class for you. Expand Resources and notice the template generated a separate nib,ViewBase_iPadViewController.xib, for the “ViewBase_iPad”.

Step 4: In the ViewBase_iPadViewController.h file, we have created instance of UILabel and UIImage class. Define one IBAction method. So make the following changes.

#import <UIKit/UIKit.h>

@interface ViewBase_iPadViewController : UIViewController {
       
 IBOutlet UILabel *myLabel;
 IBOutlet UIImage *myImage;

}

@property(nonatomic,retain) IBOutlet UILabel *myLabel;
@property(nonatomic,retain) IBOutlet UIImage *myImage;

(IBAction)ButtonPressed:(id)sender;

Step 5: Double click the ViewBase_iPadViewController.xib file and open it to the Interface Builder.First drag the Image View from the library and place it to the View window. Next drag label and Round Rect from the library and place it to the view window. Select the Round Rect from the view window and bring up Connection iNspector. Drag from the Touch Up Inside to the File’s Owner icon and select ButtonPressed: method. Connect File’s Owner icon to the View icon and select view and connect File’s Owner icon to the label select myLabel. Now save the ViewBase_iPadViewController.xib file, close it and go back to the Xcode.

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

(IBAction)ButtonPressed:(id)sender{

myLabel.text = @"Welocome to the Real World!!!";
}

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

You can Download SourceCode from here ViewBase_iPad

Download Apple WWDC 2010 Session Videos and Source Code

This might be a bit late, but just in case you missed this one and did not get the email from Apple – please do have a look! You don’t need to purchase the DVDs if you missed this years Apple WWDC session. To access them, all you need is a registered Apple developer account from – http://developer.apple.com/videos/wwdc/2010/. Grab them in both low and high definition, and if you don’t have an account ask your friendly neighbor or get on Youtube or some other video sharing sites to see what is uploaded there :)

Here is the link – Must Watch WWDC 2010 Keynotes!

Mobile Report by Distimo, June 2010 – A Must Read for Business Intelligence Data

This report covers the Apple App Store for iPad, the Apple App Store for iPhone, BlackBerry App World (Worldwide), Google Android Market, Nokia Ovi Store, Palm App Catalog and Windows Marketplace for Mobile for May 2010 in the United States.

The major findings are:

More than 50% of applications are priced below or equal to $2.00 in all stores, with the exception of BlackBerry App World and Windows Marketplace for Mobile.

The average price of all paid applications and the 100 most popular paid applications in the Apple App Store for iPad ($4.65) is higher than in the Apple App Store for iPhone ($4.01). However, the average price of the 100 top grossing applications is higher on the Apple App Store for iPhone.

Google Android Market has the largest share of free applications (57%) and Windows Marketplace for Mobile has the smallest (22%).

Twitter, Inc. published their native application in the Apple App Store and Google Android Market, becoming the monthly number 10 free application in the Apple App Store for iPhone, and the number 6 free application in Google Android Market.

Nine out of the ten most popular free applications and eight out of ten most popular paid applications in the Apple App Store for iPhone are games.

In the competitive e-reader market, both the iBooks application by Apple, Inc., and the Kindle application by Amazon.com are ranked among the 10 most popular free applications in the Apple App Store for iPad. Apple’s application is ranked number one however, and Amazon’s application is ranked number ten.

Five out of the ten most popular free applications in Windows Marketplace for Mobile are published by Microsoft Corporation.

You may download the entire report for free here!

Display WebPage and AudioFile play in TabBar Application

This is the TabBar application. In this application we will see how to display Web page and play audio file in the iPad. We will create this application using TabBar Application Template.

Step 1: Create a TabBar application using template. Give the application name “Tabbar_Videoplay_iPad”.

Step 2: code 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 TabBarApplication_iPadViewController class for you. Expand Resources and notice the template generated a separate nib,TabBarApplication_iPadViewController.xib, for the “TabBarApplication_iPad”.

Step 4: We need to add UIViewController class in the project . Select classes -> Add -> New Files -> Select UIViewController class and give the class name “AudioPlayViewController”. Select corresponding .xib file and targeted for iPad.

Step 5: We have added AudioToolbox and AVFoundation framework in the Frameworks folder.

Step 6: We need to add two music file in the resource folder. Give the name of the music file “sound.aif”,”music.mp3″.

Step 7: In the FirstViewController.h file we have created instance of UIWebView class . So make the following changes in the file.

#import <UIKit/UIKit.h>

@interface FirstViewController : UIViewController {
  IBOutlet UIWebView *webDisplay;
}
@property(nonatomic,retain) UIWebView *webDisplay;

Step 8: Double click the MainWindow.xib file and open it to the Interface Builder. Select the FirstViewController from the TabBar Controller and bring up Attribute Inspector and delete the NIB name . Now drag the WebView from the library and place it to the view window. Select the first tab from the view window and bring up Connection Inspector and connect webDisplay to the Web View. Save the MainWindow.xib file and close it and go back to the Xcode.

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

(void)viewDidLoad {
       
        NSString *urlAddress = @"http://www.google.com";
        NSURL *url = [NSURL URLWithString:urlAddress];
        NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
        [webDisplay loadRequest:requestObj];
       
    [super viewDidLoad];
}

Step 10: In the AudioViewController.h file , we have import AudioToolbox and AVFoundation framework. Create an instance of  AVAudioPlayer and UIButton class. Define two IBAction method. So make the following changes in the file.

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

@interface AudioPlayViewController : 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 11: Double click the AudioPlayViewController.xib file and open it to the view window. First drag the two Round Rect from the library and place it to the view window and give the name “Play Sound” , “Play Song”. Select the  ”Play Sound” button and bring up connection Inspector and drag Touch Up Inside to the File Owner icon select playSound: action. Do the same thing for the “Play Song”  button and select the playSong: action. Connect File’s Owner icon to the “Play Song” button and select StartStopSound. Now save the AudioPlayViewController.xib file, close it and go back to the Xcode.

Step 12: Open the AudioPlayViewController.m file and make the following changes:

(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 13: Double click the MainWindow.xib file and open it to the Interface Builder. Select the ViewController from the TabBar Controller  in MainWindow and bring up Identity Inspector and change the class name into AudioPlayViewController and bring up Attribute Inspector, set the NIB name into “AudioPlayViewController”. Now save the MainWindow.xib file, close it and go back to the Xcode.

Step 14: Now Compile the application and run it in the Simulator.

You can Download SourceCode from here Tabbar_Videoplay_iPad

Mail Send from iPad

This is the very simple application. In this application we will see how to mail send from the iPad.

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

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 MailComposerViewController class for you. Expand Resources and notice the template generated a separate nib, MailComposerViewController.xib, for the “MailComposer”.

Step 4: We need to add MessageUI Framework. Select Frameworks folder ->Add -> Existing Framework -> Add MessageUI Framework.

Step 5: In the MailComposerViewController.h file , we have import MessageUI framework. Create an instance of UIButton class and add one buttonPressed method. So make the following changes in the file.

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

@interface MailComposerViewController : UIViewController
<MFMailComposeViewControllerDelegate>
{
        IBOutlet UIButton *button;
}

(IBAction)buttonPressed;

Step 6: Double click MailComposerViewController.xib file and open it to the Interface Builder. First drag the Round Rect button from the library and place it to the view window. Connect File’s Owner icon to the View icon and select view. Drag File’s Owner icon to the round Rect button and select button and select the Round Rect button and bring up Connection Inspector next drag Touch Up Inside to the File’s Owner icon and select buttonPressed: action. Now save the MailComposerViewController.xib file, close it and go back to the Xcode.

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

(void)viewDidLoad {
        if ([MFMailComposeViewController canSendMail])
                button.enabled = YES;
}

(IBAction)buttonPressed {
        MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
        mailController.mailComposeDelegate = self;
        [mailController setSubject:@"Hello World"];
        [mailController setMessageBody:@"This is the MailSend Application…." isHTML:NO];
        [self presentModalViewController:mailController animated:YES];
        [mailController release];
}

(void)mailComposeController:(MFMailComposeViewController*)mailController didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
        [self becomeFirstResponder];
        [self dismissModalViewControllerAnimated:YES];
}

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

You can Download SourceCode from here MailComposer

Image change using touch function in iPhone

In this application we will see how to images change using touch function.

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

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: We need to add UIView class i the project. Select Classes -> Add -> New File -> Cocoa Touch Class -> Objective C class -> select UIView from the Subclass of. Give the file name “BallView”.

Step 4: We have added two resources in the Resources folder. Give the name of the resource “1.png”,”2.png”.

Step 5: In the MovingBall12AppDeleagte.h file, we have added BallView class, NSTimer , so make the following changes in the file.

#import <UIKit/UIKit.h>

@class BallView;

@interface MovingBall12AppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
        BallView *ballView;
        int count;
        NSTimer *ViewTimer;
       
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet BallView *ballView;
@property (nonatomic, retain) IBOutlet NSTimer *ViewTimer;

Step 6: Open the BallView.h file, we have added UIImageView, UILabel, NSTimer, so make the following chnages:

#import <UIKit/UIKit.h>

@interface BallView : UIView {
       
        NSTimer *ViewTimer;
        UIImageView *theBall;
        UILabel *touchMe;
        CGRect touchMeFrame;
        int count,switcher;
        int directionX, directionY;
        BOOL gameRunning;
        NSArray *images;
}

@property(nonatomic,retain) NSTimer *ViewTimer;
@property(nonatomic,retain) IBOutlet UIImageView *theBall;
@property(nonatomic,retain) IBOutlet UILabel *touchMe;
@property(nonatomic,retain) NSArray *images;

@property CGRect touchMeFrame;
@property int directionX, directionY;
@property BOOL gameRunning;

Step 7: Double click the MainWindow,xib file and open it to the Interface Builder. Double click the window icon from the main window and open it , first drag the View from the library and place it to the window. Next drag label and ImageView from the library and place it to the view window. Select the View from the main window and bring up Identity Inspector and change the class name into BallView. Connect BallView to the label and select touchMe,and connect BallView to the ImageView and select the theBall (See the figure below). Now save MainWindow.xib file, close it and go back to the Xcode.

Step 8: Open the BallView.m fie make the following changes in the file.

(void)onTimer {
        CGPoint center = theBall.center;
       
        float newX = center.x + directionX;
        float newY = center.y + directionY;
       
        int rndX = rand() % 3 + 1;
        int rndY = rand() % 3 + 1;
       
        int screenX = self.frame.origin.x + self.frame.size.width;
        int screenY = self.frame.origin.y + self.frame.size.height;
       
        BOOL changed = NO;
        if (newX < 0) {
                directionX = rndX;
                newX = 0;
                changed = YES;
        } else if (newX > screenX) {
                directionX = rndX;
                newX = screenX;
                changed = YES;
        }
       
        if (newY < 0) {
                directionY = rndY;
                newY = 0;
                changed = YES;
        } else if (newY > screenY) {
                directionY = rndY;
                newY = screenY;
                changed = YES;
        }
       
        if ((rand() % 1000) > 997) {
                directionY *= 1;
                changed = YES;
        }
       
        if ((rand() % 1000) > 997) {
                directionX *= 1;
                changed = YES;
        }
       
        if (changed == YES) {
                int img = switcher++ % (int)[images count];
                theBall.image = [images objectAtIndex:img];
               
        }
       
        CGPoint newCenter = CGPointMake(newX, newY);
        [theBall setCenter:newCenter];
       
}

(void)toggleTimer:(int)withCount {
        if (withCount % 2 != 0) {
                [ViewTimer invalidate];
                touchMe.backgroundColor = [UIColor whiteColor];
                touchMe.textColor = [UIColor blackColor];
               
                               
                gameRunning = NO;
               
        } else {
                ViewTimer = [NSTimer scheduledTimerWithTimeInterval:0.0075 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];  
                touchMe.backgroundColor = [UIColor blackColor];
                touchMe.textColor = [UIColor whiteColor];
               
                gameRunning = YES;
        }
}

(void)doInitialSetup {
        sranddev();
       
        count = 0;
       
        int rndX = rand() % 3 + 1;
        int rndY = rand() % 3 + 1;
       
        directionX = rndX;
        directionY = rndY;
       
        UIImage *img1 = [UIImage imageNamed:@"1.png"];
        UIImage *img2 = [UIImage imageNamed:@"2.png"];
       
        self.images = [NSArray arrayWithObjects:img1, img2, nil];
       
        int img = (int)count % (int)[images count];
        theBall.image = [images objectAtIndex:img];
       
        gameRunning = NO;
}

(BOOL) isPointInTouchMe:(CGPoint)point {
        return (point.x >= touchMe.frame.origin.x
                        && point.x <= touchMe.frame.origin.x + touchMe.frame.size.width
                        && point.y >= touchMe.frame.origin.y
                        && point.y <= touchMe.frame.origin.y + touchMe.frame.size.height);
}

(BOOL) isPointInTheBall:(CGPoint)point {
        return (point.x >= theBall.frame.origin.x
                        && point.x <= theBall.frame.origin.x + theBall.frame.size.width
                        && point.y >= theBall.frame.origin.y
                        && point.y <= theBall.frame.origin.y + theBall.frame.size.height);
}

(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch *touch = [touches anyObject];
        CGPoint point = [touch locationInView:self];
       
        if ([self isPointInTouchMe:point]) {
                [self toggleTimer:count++];
        }
       
}
(void) awakeFromNib {
        [self doInitialSetup];
}

(id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
                [self doInitialSetup];
    }
    return self;
}

(void)drawRect:(CGRect)rect {
        [super drawRect:rect];
}

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

You can Download SourceCode from here MovingBall12

That Flash on the iPhone

I am not quite sure how often Flash has been discussed on the iPhone and how often we have seen prototypes running on it. Given the development of HTML5 as well as the memory and battery issues that come with Flash, Flash is turning out to be a nice-to-have feature and not so much a must have. But if you really must run Flash on an iPhone, now you can, thanks to Frash that runs on jailbroken iPhones. We haven’t tested it yet, but we thought you would like to know. If you run it, keep in mind that Comex says that Frash is not what you would describe as stable.

Of course, there is now an interesting legal situation that legalizes jailbreaking, even if such a move still voids the warranty of the iPhone. We doubt that Flash will become a major deal on the iPhoen, but it is worth watching whether this story develops.

Apple is unlikely to change its opinion and if you forget Mark Papermaster’s departure from the company, it is rather quiet about the phone lately. Despite the success of Android, Apple appears to be still selling every iPhone it can make and the Apple Store still says that there is a delay between your order and actual delivery. Sterne Agee analyst Vijay Rakesh this morning told investors that Apple is likely to address this situation, especially since the iPhone 4 is making its way to a total of 88 countries by the end of September. Q3 orders have been increased to more than 10 million, according to Rakesh, which would translate into a 20% production increase over Q2.

We should see data and app use still increase over the next months. For those of you who are keeping track of the numbers, Google recently said that Android is selling some 6 million phones every month now.

That Flash on the iPhone

I am not quite sure how often Flash has been discussed on the iPhone and how often we have seen prototypes running on it. Given the development of HTML5 as well as the memory and battery issues that come with Flash, Flash is turning out to be a nice-to-have feature and not so much a must have. But if you really must run Flash on an iPhone, now you can, thanks to Frash that runs on jailbroken iPhones. We haven’t tested it yet, but we thought you would like to know. If you run it, keep in mind that Comex says that Frash is not what you would describe as stable.

Of course, there is now an interesting legal situation that legalizes jailbreaking, even if such a move still voids the warranty of the iPhone. We doubt that Flash will become a major deal on the iPhoen, but it is worth watching whether this story develops.

Apple is unlikely to change its opinion and if you forget Mark Papermaster’s departure from the company, it is rather quiet about the phone lately. Despite the success of Android, Apple appears to be still selling every iPhone it can make and the Apple Store still says that there is a delay between your order and actual delivery. Sterne Agee analyst Vijay Rakesh this morning told investors that Apple is likely to address this situation, especially since the iPhone 4 is making its way to a total of 88 countries by the end of September. Q3 orders have been increased to more than 10 million, according to Rakesh, which would translate into a 20% production increase over Q2.

We should see data and app use still increase over the next months. For those of you who are keeping track of the numbers, Google recently said that Android is selling some 6 million phones every month now.

The Foundry’s CameraTracker Giveaway!

Following Part 1 and Part 2 of the CameraTracker Overview, we conclude today with Part 3. We’ll composite our 3D light rays into our final scene with dust interaction.

We all love new plug-ins, and we all love free stuff! So, instead of just showing off The Foundry’s new CameraTracker plug-in, we figured we’d give a few licenses away to our loyal viewers! Details below!


Tutorial

Download Tutorial .flv

File size 156MB


CameraTracker Giveaway Details

We Are Giving Away:

  • 3x Licenses of The Foundry’s CameraTracker plug-in ($250 value!)

CameraTracker will allow matchmoving directly inside After Effects!

The same production tested algorithm seen in NukeX, a cutting edge VFX tool used on films such as ‘Avatar’ & ‘Iron Man II,’ right inside the After Effects environment. Invaluable for integrating VFX and motion graphics into moving camera shots!


How To Enter The Giveaway:

All you have to do is log in to your Twitter or Facebook below and tell the world what you’re after! You’ll get one entry for this…. BUT! Get this… For each person that retweets or enters through your facebook post, you’ll get another entry! We’re not gonna hack your facebook and change your gender (though we would if we knew how)… We’re just having you log into to help spread the word… that’s all. We will be closing this giveaway this Friday, the 13th at 12pm noon, EST.

Enter Through Twitter:

Enter Through Facebook:


The Foundry’s CameraTracker Giveaway!

Following Part 1 and Part 2 of the CameraTracker Overview, we conclude today with Part 3. We’ll composite our 3D light rays into our final scene with dust interaction.

We all love new plug-ins, and we all love free stuff! So, instead of just showing off The Foundry’s new CameraTracker plug-in, we figured we’d give a few licenses away to our loyal viewers! Details below!


Tutorial

Download Tutorial .flv

File size 156MB


CameraTracker Giveaway Details

We Are Giving Away:

  • 3x Licenses of The Foundry’s CameraTracker plug-in ($250 value!)

CameraTracker will allow matchmoving directly inside After Effects!

The same production tested algorithm seen in NukeX, a cutting edge VFX tool used on films such as ‘Avatar’ & ‘Iron Man II,’ right inside the After Effects environment. Invaluable for integrating VFX and motion graphics into moving camera shots!


How To Enter The Giveaway:

All you have to do is log in to your Twitter or Facebook below and tell the world what you’re after! You’ll get one entry for this…. BUT! Get this… For each person that retweets or enters through your facebook post, you’ll get another entry! We’re not gonna hack your facebook and change your gender (though we would if we knew how)… We’re just having you log into to help spread the word… that’s all. We will be closing this giveaway this Friday, the 13th at 12pm noon, EST.

Enter Through Twitter:

Enter Through Facebook:


Quick Tip: How to Create Transparent Gradients Using Blends


Introduction

It wasn’t until Illustrator CS4 that you were able to create transparent gradients. However there is a way to create them with any version of CS. By using blends, you can create a variety of radial and linear gradients, just as you can in CS4+.

Continue reading “Quick Tip: How to Create Transparent Gradients Using Blends”

Quick Tip: How to Create Transparent Gradients Using Blends


Introduction

It wasn’t until Illustrator CS4 that you were able to create transparent gradients. However there is a way to create them with any version of CS. By using blends, you can create a variety of radial and linear gradients, just as you can in CS4+.

Continue reading “Quick Tip: How to Create Transparent Gradients Using Blends”