home

Friday, March 16, 2012

temp converter part two

8. After ViewController.h done then click on ViewController.m, you could find the code at ViewController.m like the code below:




//
//  ViewController.m
//  converter
//
//  Created by.... on....
//  Copyright (c) 2012 your company. All rights reserved.
//

#import "ViewController.h"

@implementation ViewController
@synthesize fahrenheit;
@synthesize celsius;

*Note = these codes below came from IBOutlet on ViewController.h that we made it before.

@synthesize fahrenheit;
@synthesize celsius;

next step is =

insert the following code just below the code

-(void)viewDidLoad
{
    [super viewDidLoad]; 

the code is =

fahrenheit.keyboardType = UIKeyboardTypeDecimalPad;


9.  Change the code below =

- (IBAction)convert:(id)sender {
}

copy and paste with the code below =

 - (IBAction)convert:(id)sender {
    float x = [[fahrenheit text] floatValue];
    float y = (x - 32.0f) * 5.0f / 9.0f;
    [celsius setText : [NSString stringWithFormat:@"%.3.2f", y]];
    [fahrenheit resignFirstResponder];
}




then run the application, have a nice try 








Continue Reading...- temp converter part two />

temp converter

Before you make temp converter,you would like to see the first tutorial

In this tutorial I would like to show you how to make a simple temperature converter unit. The basic formula in this case is


C=(F-32).5/9

c = celsius, F = Fahrenheit
Celsius equal (Fahrenheit - 32) multiplied by 5/9

And step by step how to make this apps 

1. Open Xcode and create a new project. Choose a single view apps and Fill the product name = converter,company identifier = name of your company, class prefix = leave it blank, device family= iphone or ipad or universal, and use Storyboard then press Next button
2.For ease you could create and place your project on your dekstop,then you will see the first page of Xcode like the image below



Press the main Storyboard 

3. After that for the next page you will see on your storyboard like an image below, we could change the background image from default to another background on the right side 



4. Drag and drop two label buttons, two text buttons, and one button in to storyboard,then change those label to Fahrenheit and Celsius,leave the text button blank,and change the button to Convert button 



5. Then insert the code to ViewController.h, on the text button please click right at your mouse----->hold then drag and drop below the code 

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController 


6. Fill the name of the text label (Fahrenheit and Celsius) you could see the image below then press connect


*NOTE =
connection = Outlet
name = Fahrenheit and Celsius
Type = UITextField 




7. And also the convert button fill the name of it. Change the button to Action 





continued on part two


Continue Reading...- temp converter />