In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains how to write the code for iOS to realize the simple calculator. Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to write the code for iOS to implement a simple calculator".
Initial contact view, made a simple calculator, basically simple calculation is no problem, not very perfect, there may be some bug, continue to work hard.
/ ViewController.m// Calculator / Created by ma c on 15 Rhythm 8 Rhythm 25.za / Copyright (c) 2015 bjsxt. All rights reserved.//#import "ViewController.h" @ interface ViewController () @ property (weak, nonatomic) IBOutlet UITextField * ResultField;@property (nonatomic,assign) CGFloat temp;@property (nonatomic,assign) CGFloat num1;@property (nonatomic,assign) CGFloat num2;@property (nonatomic,strong) NSMutableString * string;@property (nonatomic,strong) NSArray * arr;@end@implementation ViewController- (IBAction) buttonClear: (UIButton *) sender {[_ string setString:@ "] / / restart the calculation, leave the text box empty self.ResultField.text = _ string;}-(IBAction) button7: (UIButton *) sender {[_ string appendString:@ "7"]; self.ResultField.text = _ string;}-(IBAction) button8: (UIButton *) sender {[_ string appendString:@ "8"]; self.ResultField.text = _ string }-(IBAction) button9: (UIButton *) sender {[_ string appendString:@ "9]; self.ResultField.text = _ string;}-(IBAction) button4: (UIButton *) sender {[_ string appendString:@" 4 "]; self.ResultField.text = _ string;}-(IBAction) button5: (UIButton *) sender {[_ string appendString:@" 5 "]; self.ResultField.text = _ string }-(IBAction) button6: (UIButton *) sender {[_ string appendString:@ "6]; self.ResultField.text = _ string;}-(IBAction) button1: (UIButton *) sender {[_ string appendString:@" 1]; self.ResultField.text = _ string;}-(IBAction) button3: (UIButton *) sender {[_ string appendString:@ "3"]; self.ResultField.text = _ string }-(IBAction) button2: (UIButton *) sender {[_ string appendString:@ "2"]; self.ResultField.text = _ string;}-(IBAction) button0: (UIButton *) sender {[_ string appendString:@ "0]; self.ResultField.text = _ string;}-(IBAction) buttonPoint: (UIButton *) sender {[_ string appendString:@". "]; self.ResultField.text = _ string } / / trigger arithmetic event-(IBAction) buttonDiv: (UIButton *) sender {[_ string appendString:@ "/"]; self.ResultField.text = _ string;}-(IBAction) buttonMul: (UIButton *) sender {[_ string appendString:@ "*]; self.ResultField.text = _ string;}-(IBAction) buttonSub: (UIButton *) sender {[_ string appendString:@"-"]; self.ResultField.text = _ string }-(IBAction) buttonAdd: (UIButton *) sender {[_ string appendString:@ "+]; self.ResultField.text = _ string;} / / do the result operation-(IBAction) buttonEqual: (UIButton *) sender {for (int item0; I)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.