ok new this. first app please nice... working on app convert units. yes know out there want learn. problem running getting view redraw once click out of text box. dont want have click calculate button.
code:// // viewcontroller.m // medconversion // // created wayne beck on 2/23/12. // copyright (c) 2012 __mycompanyname__. rights reserved. // #import "viewcontroller.h" @interface viewcontroller () @end @implementation viewcontroller - (ibaction)reset { 1.text = @"0"; 2.text = @"0"; 3.text = @"0"; 4.text = @"0"; 5.text = @"0"; 6.text = @"0"; 7.text = @"0"; 8.text = @"0"; 9.text = @"0"; } - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event { uitouch *touch = [[event alltouches] anyobject]; if (touch.tapcount >= 1) { [1 resignfirstresponder]; [2 resignfirstresponder]; [3 resignfirstresponder]; [4 resignfirstresponder]; [5 resignfirstresponder]; [6 resignfirstresponder]; [7 resignfirstresponder]; [8 resignfirstresponder]; [9 resignfirstresponder]; } } -(ibaction) resignresponder { [1 resignfirstresponder]; [2 resignfirstresponder]; [3 resignfirstresponder]; [4 resignfirstresponder]; [5 resignfirstresponder]; [6 resignfirstresponder]; [7 resignfirstresponder]; [8 resignfirstresponder]; [9 resignfirstresponder]; } - (bool)textfieldshouldreturn:(uitextfield *)textfield { if (textfield == 1) { [1 resignfirstresponder]; double c = (5.0/9.0)*([1.text doublevalue]-32.0); double k = c - 273.15; 2.text = [[nsstring alloc]initwithformat:@"%2.1f", c]; 3.text = [[nsstring alloc]initwithformat:@"%2.1f", k]; } if (textfield == 2) { [2 resignfirstresponder]; double f = (9.0/5.0*[2.text doublevalue])+32.0; double k = [2.text doublevalue] - 273.15; 1.text = [[nsstring alloc]initwithformat:@"%2.1f", f]; 3.text = [[nsstring alloc]initwithformat:@"%2.1f", k]; } if (textfield == 3) { [3 resignfirstresponder]; double c = [3.text doublevalue] + 273.15; double f = (9.0/5.0*c)+32.0; 2.text = [[nsstring alloc]initwithformat:@"%2.1f", c]; 1.text = [[nsstring alloc]initwithformat:@"%2.1f", f]; } return yes; } /*- (void)drawrect:(cgrect)rect { // drawing code }*/ - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. } - (void)viewdidunload { [super viewdidunload]; // release retained subviews of main view. } - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { return (interfaceorientation != uiinterfaceorientationportraitupsidedown); } @end
so you're naming variables numerals?
Forums iPhone, iPad, and iPod Touch iOS Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
No comments:
Post a Comment