Sunday, February 6, 2011

How to Switch work in iPhone


How to Make a Persuasive Business PortfolioHow to Switch work in iPhone ? iPhone Tutorial 2011 in simple ways. This is the very simple example. In this example we will see how to Switch function worked. This iPhone Tutorial blog offers a comprehensive resource for iPhone SDK development including iOS4, iPad programming. We also run a 12 week iphone course taught by real tutors who guide you through iPhone development step-by-step via iPhone SDK Videos and programming worksheets.

You may also want to take a look at the following related posts:

  1. Top 40 best free iPhone apps
  2. 100 Most Wanted Useful & Free Mac Apps
  3. 100 Most Wanted so Useful & Free iPad Apps
  4. 100 Most Useful iPhone Apps Free
  5. The Top iPhone Application Resource Sites
  6. Our iPhone Apps sections has a number of iPhone Applications and gaming apps related posts.

Also don’t forget to subscribe! or be a fan on facebook must have web rss ahli desain

This iphone dev blog is regularly updated with free iphone tutorial including iPad and iOS4 training. Our iPhone Course has given iphone training to over 400 iphone developer students worldwide. Feel free to browse and subscribe to our iphone feed to get regular updates. If you have any iphone SDK tutorial related questions, please ask us via the iPhone Dev Help page.

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

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

Step 4: Open the SwitchONViewController.h file and make the following changes in the file.

#import <UIKit/UIKit.h>

@interface SwitchONViewController : UIViewController {

IBOutlet        UILabel *display;
IBOutlet UISwitch *switch1;
       
}

@property (nonatomic,retain) UISwitch *switch1;

@property (nonatomic,retain) UILabel *display;

-(IBAction)messagedisplay:(id)sender;

Step 5: Double click the SwitchONViewController.xib file and open it to the Interface Builder. Now first drag the switch from the library and place it to the view window and drag the label from the library and place it to the view window. Select the label from the view window and bring up attribute inspector, give the Text name “Please Switch me OFF!” . Select the switch from the view window and bring up Connection Inspector, connect Value Changed to the File’s Owner icon and select messagedisplay:, Connect File’s Owner icon to the switch and select switch1. Now save it close it and go back to the Xcode.

Step 6: In the SwitchONViewController.m file make the following changes.

-(IBAction)messagedisplay:(id)sender
{
        NSString *message1 = [[NSString alloc] initWithFormat:@"Please switch me OFF!"];
        NSString *message2 = [[NSString alloc] initWithFormat:@"Please switch me ON!"];
       
        if (switch1.on){               
                display.text = @"Please switch me OFF!";
                [message1 release];
        }
        else {  
                display.text = message2;
                [message2 release];
        }
       
}

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

You can Download SourceCode from here SwitchON

You may also want to take a look at the following related posts:

  1. Top 40 best free iPhone apps
  2. 100 Most Wanted Useful & Free Mac Apps
  3. 100 Most Wanted so Useful & Free iPad Apps
  4. 100 Most Useful iPhone Apps Free
  5. The Top iPhone Application Resource Sites
  6. Our iPhone Apps sections has a number of iPhone Applications and gaming apps related posts.

Also don’t forget to subscribe! or be a fan on facebook must have web rss ahli desain

0 comments:

Post a Comment

 

Copyright 2010 All Rights Reserved | Super Template by Ilmu Komputer | Modified by Ilmu Grafis | Original Wordpress theme by Ahli Desain