From 146b3930e0e3ae1e21a9dcb3fb7f9fdc5d104a99 Mon Sep 17 00:00:00 2001 From: FloPeters Date: Tue, 11 Apr 2017 11:19:23 +0200 Subject: [PATCH] BMI mit Slyder Noch nicht optimal Formatiert --- simpleui/Info.plist | 4 ++ simpleui/ViewController.swift | 44 ++++++++++++++ simpleui/main.storyboard | 110 ++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+) diff --git a/simpleui/Info.plist b/simpleui/Info.plist index 05e4576..e121985 100644 --- a/simpleui/Info.plist +++ b/simpleui/Info.plist @@ -43,5 +43,9 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + NSLocationAlwaysUsageDescription + show user location + NSLocationWhenInUseUsageDescription + show user location diff --git a/simpleui/ViewController.swift b/simpleui/ViewController.swift index 346b847..a40d652 100644 --- a/simpleui/ViewController.swift +++ b/simpleui/ViewController.swift @@ -10,5 +10,49 @@ import UIKit class ViewController: UIViewController { + @IBOutlet weak var gewichtLabel: UILabel! + @IBOutlet weak var größeLabel: UILabel! + + + override func viewDidLoad() { + super.viewDidLoad() + + slyderGröße(slyderGröße) + slyderGewicht(slyderGewicht) + + bmiLabel.text = "Hier wird dein BMI stehen" + } + + + @IBAction func slyderGewicht(_ sender: Any) { + + gewichtLabel.text = "\(slyderGewicht.value)" + + } + + @IBOutlet weak var slyderGewicht: UISlider! + @IBAction func slyderGröße(_ sender: Any) { + + größeLabel.text = "\(slyderGröße.value)" + } + + + + @IBOutlet weak var slyderGröße: UISlider! + + + + + @IBAction func berechneBMI(_ sender: Any) { + + let größe = slyderGröße.value + let gewicht = slyderGewicht.value + + let bmi = gewicht / pow(größe,2) + + bmiLabel.text = "\(bmi)" + + } + @IBOutlet weak var bmiLabel: UILabel! } diff --git a/simpleui/main.storyboard b/simpleui/main.storyboard index 764f719..fd21bd4 100644 --- a/simpleui/main.storyboard +++ b/simpleui/main.storyboard @@ -20,11 +20,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +