




已阅读5页,还剩9页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#import ViewController.h/implementation ViewControllersynthesize outPut=_outPut,biao=_biao;synthesize Button0,Button2,Button3,Button4,Button5,Button6,Button1,Button7,Button8,Button9,jianButton,chuButton,addButton,chenButton,denButton,shanButton,dianButton,gui0Button;synthesize textFiele,aStr=aStr,bStr=bStr,abStr=abStr,ji=ji,cun=_cun,suan=_suan,ji2=ji2,ji3=ji3;-(void)dealloc/鍦ealloc涓敤瀹炰緥鍙橀噺鍚嶅瓧release aStr release;bStr release;abStr release; super dealloc;- (void)didReceiveMemoryWarning super didReceiveMemoryWarning; / Release any cached data, images, etc that arent in use.#pragma mark - View lifecycle- (void)viewDidLoad super viewDidLoad; self.aStr=NSMutableString stringWithFormat:; self.ji=0; self.cun=0; self.biao=0; self.suan=0; self.ji3=0; /UIImage鍥剧墖 UIImageView 鍥剧墖瑙嗗浘 UIImage *image=UIImage imageNamed:dd.png; UIImageView *imageView=UIImageView alloc initWithImage:image; self.view addSubview:imageView; imageView release; /UILable 鏍囩 _outPut=UILabel alloc initWithFrame:CGRectMake(20, 20, 290, 50); _outPut setText:0; _outPut setTextAlignment:UITextAlignmentRight; _outPut setTextColor:UIColor whiteColor; _outPut setBackgroundColor:UIColor clearColor; _outPut setFont:UIFont fontWithName:Didot size:40; self.view addSubview:_outPut; _outPut release; /UITextFile 鏂囨湰瀛楁 textField=UITextField alloc initWithFrame:CGRectMake(0, 0, 300, 20); textField setBackgroundColor:UIColor clearColor; textField setTextColor:UIColor whiteColor; textField addTarget:self action:selector(acc:) forControlEvents:UIControlEventEditingDidEndOnExit; self.view addSubview:textField; textField release; /UIButton 鎸夐挳 (320-4*50)/5 320/4 Button7=UIButton buttonWithType:1; Button7 setFrame:CGRectMake(24, 95, 65, 65); Button7 setTitle:7 forState:UIControlStateNormal; Button7 setTitleColor:UIColor orangeColor forState:UIControlStateNormal; Button7 setTag:7; Button7 addTarget:self action:selector(numberPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:Button7; Button8=UIButton buttonWithType:1; Button8 setFrame:CGRectMake(98, 95, 65, 65); Button8 setTitle:8 forState:UIControlStateNormal; Button8 setTitleColor:UIColor purpleColor forState:UIControlStateNormal; Button8 setTag:8; Button8 addTarget:self action:selector(numberPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:Button8; Button9=UIButton buttonWithType:1; Button9 setFrame:CGRectMake(172, 95, 65, 65); Button9 setTitle:9 forState:UIControlStateNormal; Button9 setTitleColor:UIColor redColor forState:UIControlStateNormal; Button9 setTag:9; Button9 addTarget:self action:selector(numberPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:Button9; chuButton =UIButton buttonWithType:1; chuButton setFrame:CGRectMake(246, 95, 65, 65); chuButton setTitleColor:UIColor blueColor forState:UIControlStateNormal; chuButton setTag:10; chuButton setTitle:/ forState:UIControlStateNormal; chuButton addTarget:self action:selector(suanPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:chuButton; / Button4=UIButton buttonWithType:1; Button4 setFrame:CGRectMake(24, 170, 65, 65); Button4 setTitle:4 forState:UIControlStateNormal; Button4 setTitleColor:UIColor redColor forState:UIControlStateNormal; Button4 setTag:4; Button4 addTarget:self action:selector(numberPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:Button4; Button5=UIButton buttonWithType:1; Button5 setFrame:CGRectMake(98, 170, 65, 65); Button5 setTitle:5 forState:UIControlStateNormal; Button5 setTitleColor:UIColor redColor forState:UIControlStateNormal; Button5 setTag:5; Button5 addTarget:self action:selector(numberPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:Button5; Button6=UIButton buttonWithType:1; Button6 setFrame:CGRectMake(172, 170, 65, 65); Button6 setTitle:6 forState:UIControlStateNormal; Button6 setTitleColor:UIColor redColor forState:UIControlStateNormal; Button6 setTag:6; Button6 addTarget:self action:selector(numberPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:Button6; chenButton=UIButton buttonWithType:1; chenButton setFrame:CGRectMake(246, 170, 65, 65); chenButton setTitle:* forState:UIControlStateNormal; chenButton setTitleColor:UIColor redColor forState:UIControlStateNormal; chenButton setTag:11; chenButton addTarget:self action:selector(suanPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:chenButton; / Button1=UIButton buttonWithType:1; Button1 setFrame:CGRectMake(24, 245, 65, 65); Button1 setTitle:1 forState:UIControlStateNormal; Button1 setTitleColor:UIColor redColor forState:UIControlStateNormal; Button1 setTag:1; Button1 addTarget:self action:selector(numberPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:Button1; Button2=UIButton buttonWithType:1; Button2 setFrame:CGRectMake(98, 245, 65, 65); Button2 setTitle:2 forState:UIControlStateNormal; Button2 setTitleColor:UIColor redColor forState:UIControlStateNormal; Button2 setTag:2; Button2 addTarget:self action:selector(numberPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:Button2; Button3=UIButton buttonWithType:1; Button3 setFrame:CGRectMake(172, 245, 65, 65); Button3 setTitle:3 forState:UIControlStateNormal; Button3 setTitleColor:UIColor blueColor forState:UIControlStateNormal; Button3 setTag:3; Button3 addTarget:self action:selector(numberPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:Button3; jianButton=UIButton buttonWithType:1; jianButton setFrame:CGRectMake(246, 245, 65, 65); jianButton setTitle:- forState:UIControlStateNormal; jianButton setTitleColor:UIColor blackColor forState:UIControlStateNormal; jianButton setTag:12; jianButton addTarget:self action:selector(suanPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:jianButton; / Button0=UIButton buttonWithType:1; Button0 setFrame:CGRectMake(24, 320, 65, 65); Button0 setTitle:0 forState:UIControlStateNormal; Button0 setTitleColor:UIColor magentaColor forState:UIControlStateNormal; Button0 setTag:0; Button0 addTarget:self action:selector(numberPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:Button0; dianButton=UIButton buttonWithType:1; dianButton setFrame:CGRectMake(98, 320, 65, 65); dianButton setTitle:. forState:UIControlStateNormal; dianButton setTitleColor:UIColor redColor forState:UIControlStateNormal; dianButton setTag:13; dianButton addTarget:self action:selector(dianPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:dianButton; shanButton=UIButton buttonWithType:1; shanButton setFrame:CGRectMake(172, 320, 65, 65); shanButton setTitle:Delete forState:UIControlStateNormal; shanButton setTitleColor:UIColor magentaColor forState:UIControlStateNormal; shanButton setTag:14; shanButton addTarget:self action:selector(deletePressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:shanButton; addButton=UIButton buttonWithType:1; addButton setFrame:CGRectMake(246, 320, 65, 65); addButton setTitle:+ forState:UIControlStateNormal; addButton setTitleColor:UIColor redColor forState:UIControlStateNormal; addButton setTag:15; addButton addTarget:self action:selector(suanPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:addButton; / gui0Button=UIButton buttonWithType:1; gui0Button setFrame:CGRectMake(32, 395, 120, 65); gui0Button setTitle:娓呴浂 forState:UIControlStateNormal; gui0Button setTitleColor:UIColor redColor forState:UIControlStateNormal; gui0Button setTag:16; gui0Button addTarget:self action:selector(qinPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:gui0Button; denButton=UIButton buttonWithType:1; denButton setFrame:CGRectMake(185, 395, 120, 65); denButton setTitle:= forState:UIControlStateNormal; denButton setTitleColor:UIColor redColor forState:UIControlStateNormal; denButton setTag:17; denButton addTarget:self action:selector(suanPressen:) forControlEvents:UIControlEventTouchUpInside; self.view addSubview:denButton; - (void)viewDidUnload super viewDidUnload; self.outPut=nil; self.textFiele=nil; self.Button0=nil;self.Button2=nil;self.Button3=nil;self.Button4=nil; self.Button5=nil;self.Button6=nil;self.Button7=nil;self.Button8=nil; self.Button9=nil;self.jianButton=nil;self.chuButton=nil; self.addButton=nil; self.chenButton=nil;self.denButton=nil; self.shanButton=nil;self.dianButton=nil;self.gui0Button=nil; self.Button1=nil; / Release any retained subviews of the main view. / e.g. self.myOutlet = nil;- (void)viewWillAppear:(BOOL)animated super viewWillAppear:animated;- (void)viewDidAppear:(BOOL)animated super viewDidAppear:animated;- (void)viewWillDisappear:(BOOL)animatedsuper viewWillDisappear:animated;- (void)viewDidDisappear:(BOOL)animatedsuper viewDidDisappear:animated;- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation / Return YES for supported orientations return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);/-(void)numberPressen:(UIButton *)sender if (self.outPut.text.length6) return; if (self.biao!=0) ji2=0;ji3=0; self.suan=1; if (self.biao=1) self.aStr=NSMutableString stringWithFormat:; self.outPut.text=aStr stringByAppendingFormat:%lu,sender.tag; self.aStr=NSMutableString stringWithFormat:%,self.outPut.text; self.biao=0; return; else / self.outPut.text=aStr stringByAppendingFormat:%lu,sender.tag; /self.aStr=NSMutableString stringWithFormat:%,self.outPut.text; self.aStr appendFormat:%lu,sender.tag; self.outPut setText:self.aStr; return; -(void)suanPressen:(UIButton *)sender if(self.suan=0) return; if (self.ji=0) self.cun=self.outPut.text doubleValue; / if (self.ji=1) self.cun=self.cun+self.outPut.text doubleValue; if (self.ji=2) self.cun=self.cun-self.outPut.text doubleValue; if (self.ji=3) self.cun=self.cun * self.outPut.text doubleValue; if (self.ji=4) self.cun=self.cun/self.outPut.text doubleValue; / if (sender.tag=15|sender.tag=17) self.ji=1; if (sender.tag=12|sender.tag=17) self.ji=2; if (sender.tag=11|sender.tag=17) self.ji=3; if (sender.tag=10|sender.tag=17) self.ji=4; self.biao=1; self.suan=0; self.outPut.text=NSString stringWithFormat:%g,self.cun; -(void)qinPressen:(UIButton *)sender self.outPut setText:0; self.ji=0; self.cun=0; self.biao=0; self.suan=0; self.ji2=0; self.ji3=0; self.aStr=NSMutableString stringWithFormat:;-(void)dianPressen:(UIButton *)sender if (self.outPut.text=0&ji2=0) self.aStr=NSMutableString stringWithFormat:0.; self.outPut setText:self.aStr; ji2=1; return; else if(ji3=0) ji3=1; self.aStr appendFormat:.; self.outPut.text=self.aStr; -(void)deletePressen:(UIButton *)sender if (self.outPut.text!=) self.aStr deleteCharactersInRange:NSMakeRange(self.aStr.length-1, 1); self.outPut setText:self.aStr; if (self.aStr hasSuffix:.) ji2=0;ji3=0; -(void)acc:(id)sender textField resignFirstResponder;/ ViewController.h/ Calculator/ Created by bokan on 12-6-7./ Copyright (c) 2012骞?鑱傛柊55555. All rights reserved./#import interface ViewController : UIViewController /澹版槑涓哄睘鎬悗瀵硅薄涓嶆秷澶眫灞炴篃涓嶄細娑堝鍦ealloc閿姣亊鎴栬呯敤allocinit鎵嬪姩閲婃斁/灏嗘槸璋冭瘯productedit schemeobject-cexception渚嬪寮傚父 NSMutableString *aStr; NSMutableString *bStr; NSMutableString *abStr; double a; double b; double aa; int ji2; int ji; UILabel *_outPut; UIButton *Button1; UIButton *Button2; UIButton *Button3; UIButton *Button4; UIButton *Button5; UIButton *Button6; UIButton *Button7; UIButton *Button8; UIButton *Button9; UIButton *Button0; UIButton *denButton; UIButton *addButton; UIButton *jianButton; UIButton *dianButton; UIButton *gui0Button; UIButton *chenButton; UIButton *chuButton; UIButton *shanButton; UITextField *textField;property(nonatomic,retain)NSMutableString *aStr;property(nonatomic,retain)NSMutableString *bStr;property(nonatomic,retain)NSMutableString *abStr;property(nonatomic,assign)int ji,biao,suan,ji2,ji3;property(nonatomic,retain)UILabel *outPut;property(nonatomic,retain)UIButton *Button1;property(nonatomic,retain)UIButton *Button2;property(nonatomic,retain)UIButton *Button3;property(nonatomic,retain)UIButton *Button4;property(nonatomic,retain)UIButton *Button5;property(nonatomic,retain)UIButton *Button6;property(nonatomic,retain)UIButton *Button7;property(nonatomic,retain)UIButton *Button8;property(nonatomic,retain)UIButton *Button9;property(nonatomic,retain)UIButton *Button0;property(nonatomic,retain)UIButton *denButton;property(nonatomic,retain)UIButton *addButton;property(nonatomic,retain)UIButton *jianButton;property(nonatomic,retain)UIButton *dianButton;property(nonatomic,retain)UIButton *gui0Button;property(nonatomic,retain)UIButton *chenButton;property(nonatomic,retain)UIButton *chuButton;property(nonatomic,retain)UIButton *shanButton;property(nonatomic,retain)UITextField *textFiele;property(assign,nonatomic)double cun;end/ AppDelegate.m/ Calculator/ Created by bokan on 12-6-7./ Copyright (c) 2012骞?鑱傛柊55555. All rights reserved./#import AppDelegate.h#import ViewController.himplementation AppDelegatesynthesize window = _window;synthesize viewController = _viewController;- (void)dealloc _window release; _viewController release; super dealloc;- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions self.window = UIWindow alloc initWithFrame:UIScreen mainScreen bounds autorelease; / Override point for customization after application launch. self.viewController = ViewController alloc initWithNibName:ViewController bundle:nil autorelease; /self.viewController.view.backgroundColor=UIColor blackColor; self.window.rootViewController = self.viewController; self.window makeKeyAndVisible; return YES;- (void)applicationWillResignActive:(UIA
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 生产力和生产关系新质生产力
- 新护士岗前培训心得体会模版
- 科室护理工作汇报材料
- 银行营销面试题目及答案
- 银行内聘面试题目及答案
- 医院消防试题知识及答案
- 一级消防工程师模拟试题及答案
- 湿疹的护理常规
- 跨国度假紧急医疗援助服务补充协议
- 全球化市场拓展人员招聘与派遣合同
- 钢结构门头施工方案
- 住房城乡建设领域重大安全风险隐患清单
- 中兴XPON高级VUE认证考试题库(高分版)
- 化工原理课程设计-吸收塔
- 2023年云南省中考地理试卷和答案
- 三级安全教育考试试卷及答案
- 门式起重机的制作工艺
- 泌尿及男性生殖系统超声诊断医专
- 2023年高考生物试题及参考答案(江苏卷)
- 学法减分考试题库及答案500题(12123学法减分题库)
- 氢气站设计规范
评论
0/150
提交评论