質問編集履歴
1
写真以外の追加、ファイルの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,136 @@
|
|
1
|
+
「ViewController.m」
|
2
|
+
|
3
|
+
#import "ViewController.h"
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
@interface ViewController ()
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
@end
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
@implementation ViewController
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
- (void)viewDidLoad{
|
20
|
+
|
21
|
+
[super viewDidLoad];
|
22
|
+
|
23
|
+
labelBmiTitle.hidden=YES;
|
24
|
+
|
25
|
+
labelBmiText.hidden=YES;
|
26
|
+
|
27
|
+
labelBmiValue.hidden=YES;
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
-(BOOL)textFieldShouldReturn:(UITextField*)textField
|
32
|
+
|
33
|
+
{
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
[textField resignFirstResponder];
|
38
|
+
|
39
|
+
return YES;
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
- (IBAction)
|
46
|
+
|
47
|
+
{
|
48
|
+
|
49
|
+
float height = [tfHeight.text floatValue] / 100;
|
50
|
+
|
51
|
+
float weight = [tfWeight.text floatValue];
|
52
|
+
|
53
|
+
float bmiValue = weight / (height*height);
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
labelBmiValue.text = [[NSString alloc] initWithFormat:@"%.2f", bmiValue];
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
if(bmiValue < 17.6){
|
62
|
+
|
63
|
+
labelBmiText.text = @"痩せすぎです";
|
64
|
+
|
65
|
+
}else if(bmiVelue < 19.8){
|
66
|
+
|
67
|
+
labelBmiText = @"痩せ気味です";
|
68
|
+
|
69
|
+
}else if(bmiValue < 24.2){
|
70
|
+
|
71
|
+
labelBmiText = @"標準的な体重です";
|
72
|
+
|
73
|
+
}else if(bmiValue < 26.4){
|
74
|
+
|
75
|
+
labelBmiText.text = @"太り気味です";
|
76
|
+
|
77
|
+
}else {
|
78
|
+
|
79
|
+
labelBmiText.text = @"肥満気味です";
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
labelBmiTitle.hiddeo = NO;
|
86
|
+
|
87
|
+
labelBmiText.hiddeo = NO;
|
88
|
+
|
89
|
+
labelBmiValue.hidden = NO;
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
「ViewController」
|
100
|
+
|
101
|
+
#import <UIKit/UIKit.h>
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
@interface ViewController : UIViewController {
|
106
|
+
|
107
|
+
IBOutlet UITextField *tfHeight;
|
108
|
+
|
109
|
+
IBOutlet UITextField *tfWeight;
|
110
|
+
|
111
|
+
IBOutlet UIButton *btnCalc;
|
112
|
+
|
113
|
+
IBOutlet UILabel *labelBmiTitle;
|
114
|
+
|
115
|
+
IBOutlet UILabel *labelBmiValue;
|
116
|
+
|
117
|
+
IBOutlet UILabel *labelBmiText;
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
@end
|
128
|
+
|
129
|
+
|
130
|
+
|
1
|
-
![
|
131
|
+
![ViewController](d816d414e2d57c3f0c7433cb75e89764.png)
|
132
|
+
|
133
|
+
|
2
134
|
|
3
135
|
|
4
136
|
|