質問編集履歴

4

FirstViewControllerのコードを修正しました。

2017/04/14 01:50

投稿

Ruthi
Ruthi

スコア65

test CHANGED
File without changes
test CHANGED
@@ -50,6 +50,30 @@
50
50
 
51
51
 
52
52
 
53
+ //追記箇所
54
+
55
+ //身長もしくは体重に何も入力されていない場合(エラー)
56
+
57
+ if height == nil || weight == nil
58
+
59
+ {
60
+
61
+ Error.text = "正常に値が入力されていないため\n計算できません。\n再入力してください。"
62
+
63
+ }
64
+
65
+
66
+
67
+ //身長が80cm以下or220cm以上、体重が20kg以下or300kg以上(異常数値を弾く処理)
68
+
69
+ else if height! <= 80 || height! >= 220 || weight! <= 20 || weight! >= 300{
70
+
71
+ Error.text = "規定の範囲外のため\n計算できません。\n再入力してください。"
72
+
73
+ }
74
+
75
+
76
+
53
77
  //後々結果画面のテキストへ代入するBMI値や肥満度を代入する変数の宣言
54
78
 
55
79
  var Ca:String!

3

FirstViewControllerのコードを修正しました。

2017/04/14 01:49

投稿

Ruthi
Ruthi

スコア65

test CHANGED
File without changes
test CHANGED
@@ -86,23 +86,23 @@
86
86
 
87
87
  //SecondViewControllerの
88
88
 
89
- func prepare(for segue: UIStoryboardSegue, sender: Any?){
89
+ override func prepare(for segue: UIStoryboardSegue, sender: Any?){
90
-
90
+
91
- let SecondViewController = segue.destination as! SecondViewController
91
+ let Second = segue.destination as! SecondViewController
92
92
 
93
93
  //BMI値等算出された値を渡す
94
94
 
95
- SecondViewController.Cal = Ca
95
+ Second.Cal = Ca
96
-
96
+
97
- SecondViewController.Sta = St
97
+ Second.Sta = St
98
-
98
+
99
- SecondViewController.Adv = Ad
99
+ Second.Adv = Ad
100
-
100
+
101
- SecondViewController.StaWei = StWe
101
+ Second.StaWei = StWe
102
-
102
+
103
- SecondViewController.Ide = Id
103
+ Second.Ide = Id
104
-
104
+
105
- SecondViewController.Met = Me
105
+ Second.Met = Me
106
106
 
107
107
  }
108
108
 

2

FirstViewControllerのコードを修正しました。

2017/04/14 00:55

投稿

Ruthi
Ruthi

スコア65

test CHANGED
File without changes
test CHANGED
@@ -104,8 +104,6 @@
104
104
 
105
105
  SecondViewController.Met = Me
106
106
 
107
- }
108
-
109
107
  }
110
108
 
111
109
 

1

FirstViewControllerのコードを修正しました。

2017/04/14 00:01

投稿

Ruthi
Ruthi

スコア65

test CHANGED
File without changes
test CHANGED
@@ -76,42 +76,36 @@
76
76
 
77
77
  //
78
78
 
79
+
80
+
79
-
81
+ present(SecondViewController, animated: true, completion: nil)
82
+
83
+
84
+
85
+ }
80
86
 
81
87
  //SecondViewControllerの
82
88
 
83
89
  func prepare(for segue: UIStoryboardSegue, sender: Any?){
84
90
 
85
- let SecondViewController = segue.destination as! SecondViewController
91
+ let SecondViewController = segue.destination as! SecondViewController
86
-
92
+
87
- //BMI値等算出された値を渡す
93
+ //BMI値等算出された値を渡す
88
-
94
+
89
- SecondViewController.Cal = Ca
95
+ SecondViewController.Cal = Ca
90
-
96
+
91
- SecondViewController.Sta = St
97
+ SecondViewController.Sta = St
92
-
98
+
93
- SecondViewController.Adv = Ad
99
+ SecondViewController.Adv = Ad
94
-
100
+
95
- SecondViewController.StaWei = StWe
101
+ SecondViewController.StaWei = StWe
96
-
102
+
97
- SecondViewController.Ide = Id
103
+ SecondViewController.Ide = Id
98
-
104
+
99
- SecondViewController.Met = Me
105
+ SecondViewController.Met = Me
100
106
 
101
107
  }
102
108
 
103
-
104
-
105
- //画面の遷移
106
-
107
- let storyboard: UIStoryboard = self.storyboard!
108
-
109
- let nextView = storyboard.instantiateViewController(withIdentifier: "SecondView")
110
-
111
- present(nextView, animated: true, completion: nil)
112
-
113
- }
114
-
115
109
  }
116
110
 
117
111