From e6c496b45b57c708277cfcf5f743204d3019471a Mon Sep 17 00:00:00 2001 From: felix Date: Sun, 22 May 2016 23:59:36 +0200 Subject: [PATCH 1/5] seasonizer; seltsame declaration Fehler --- Seasonizer/AccessoryListViewController.swift | 33 ++++++-- Seasonizer/CanvasViewController.swift | 39 +++++---- Seasonizer/Main.storyboard | 86 +++++++++++++++++--- 3 files changed, 122 insertions(+), 36 deletions(-) diff --git a/Seasonizer/AccessoryListViewController.swift b/Seasonizer/AccessoryListViewController.swift index 1c32a19..e64745f 100644 --- a/Seasonizer/AccessoryListViewController.swift +++ b/Seasonizer/AccessoryListViewController.swift @@ -20,18 +20,41 @@ class AccessoryListViewController: UITableViewController { // MARK: User Interaction // TODO: Implement `prepareForSegue(_:sender:)` to set `selectedAccessory` when the "selectedAccessory" Segue is performed. - /* - HINT: Obtain the selected index path with: - + // HINT: Obtain the selected index path with: + + // + override func numberOfSectionsInTableView(tableView: UITableView) -> Int{ + return 1 + } + // 1 + override func tableView(tableView: UITableView, numberOfRowsInSection section:Int)->Int{ + return accessories?.count ?? 0 + } + // 2 + override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath:NSIndexPath)->UITableViewCell{ + let accessory = accessories![indexPath.row] + let cell = tableView.dequeueReusableCellWithIdentifier("accessoryCell",forIndexPath:indexPath); cell.textLabel?.text = accessory.title; cell.imageView?.image = accessory.image + return cell + } + // 3 + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?){ + // guard let indexPath = tableView.indexPathForSelectedRow else { return } - - */ + selectedAccessory = accessories![indexPath.row] + // + } + + } // MARK: - Table View Data Source + + + + // TODO: Implement the `UITableViewDataSource` protocol. diff --git a/Seasonizer/CanvasViewController.swift b/Seasonizer/CanvasViewController.swift index c8cebcb..75d9864 100644 --- a/Seasonizer/CanvasViewController.swift +++ b/Seasonizer/CanvasViewController.swift @@ -22,6 +22,7 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI /// Eine `UIImageView`, die das Foto anzeigt. @IBOutlet weak var photoImageView: UIImageView! + /// Eine View, die _über_ der `photoImageView` positioniert ist und die Accessories anzeigt. @IBOutlet weak var accessoryOverlayView: UIView! @@ -120,37 +121,39 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI // TODO: Implement `prepareForSegue(_:sender:)` to pass `allAccessories` on to `AccessoryListViewController`. - /* - HINT: The `AccessoryListViewController` should be embedded in a `UINavigationController`: + // HINT: The `AccessoryListViewController` should be embedded in a `UINavigationController`: - guard let accessoryListViewController = (segue.destinationViewController as? UINavigationController)?.topViewController as? AccessoryListViewController else { + guard let accessoryListViewController = (segue.destinationViewController as? UINavigationController)?.topViewController as? AccessoryListViewController else { return - } - */ + } // TODO: Implement an `@IBAction func unwindToCanvas(segue: UIStoryboardSegue)` Unwing Segue that the `AccessoryListViewController` can exit to. + @IBAction func unwindToCanvas(segue: UIStoryboardSegue){ + + //no implementation + } + // TODO: For the "selectedAccessory" segue, obtain the selected accessory and add it to the canvas. - /* - HINTS: + + // HINTS: - - The `AccessoryListViewController` is the segue's `sourceViewController`: + // - The `AccessoryListViewController` is the segue's `sourceViewController`: - guard let accessoryListViewController = segue.sourceViewController as? AccessoryListViewController, - selectedAccessory = accessoryListViewController.selectedAccessory else { - return - } + guard let accessoryListViewController = segue.sourceViewController as? AccessoryListViewController, + selectedAccessory = accessoryListViewController.selectedAccessory else { + return + } - - Create an `AccessoryView` from the `selectedAccessory` and set its initial position: + //- Create an `AccessoryView` from the `selectedAccessory` and set its initial position: - let accessoryView = AccessoryView(accessory: selectedAccessory) - accessoryView.center = accessoryOverlayView.convertPoint(accessoryOverlayView.center, fromView: accessoryOverlayView.superview) + let accessoryView = AccessoryView(accessory: selectedAccessory) + accessoryView.center = accessoryOverlayView.convertPoint(accessoryOverlayView.center, fromView: accessoryOverlayView.superview) - - Finally, call the `addAccessoryView(_:)` Method implemented above: + //- Finally, call the `addAccessoryView(_:)` Method implemented above: - self.addAccessoryView(accessoryView) - */ + self.addAccessoryView(accessoryView) } diff --git a/Seasonizer/Main.storyboard b/Seasonizer/Main.storyboard index 926189e..3e616f4 100644 --- a/Seasonizer/Main.storyboard +++ b/Seasonizer/Main.storyboard @@ -1,24 +1,31 @@ - + - + - - - - - - + + - - - - - + + + + + + + + + + + + + + + + @@ -46,5 +53,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 5faefd276012299e1fe0fb5e012ed43a760aa626 Mon Sep 17 00:00:00 2001 From: felix Date: Mon, 23 May 2016 12:39:51 +0200 Subject: [PATCH 2/5] lauffaehig, aber Anzeige noch problematisch ;) --- Seasonizer/AccessoryListViewController.swift | 5 ++- Seasonizer/CanvasViewController.swift | 41 +++++++++++--------- Seasonizer/Main.storyboard | 24 ++++-------- 3 files changed, 33 insertions(+), 37 deletions(-) diff --git a/Seasonizer/AccessoryListViewController.swift b/Seasonizer/AccessoryListViewController.swift index e64745f..2abe7a8 100644 --- a/Seasonizer/AccessoryListViewController.swift +++ b/Seasonizer/AccessoryListViewController.swift @@ -19,8 +19,7 @@ class AccessoryListViewController: UITableViewController { // MARK: User Interaction - // TODO: Implement `prepareForSegue(_:sender:)` to set `selectedAccessory` when the "selectedAccessory" Segue is performed. - // HINT: Obtain the selected index path with: + // override func numberOfSectionsInTableView(tableView: UITableView) -> Int{ @@ -37,6 +36,8 @@ class AccessoryListViewController: UITableViewController { return cell } // 3 + // TODO: Implement `prepareForSegue(_:sender:)` to set `selectedAccessory` when the "selectedAccessory" Segue is performed. + // HINT: Obtain the selected index path with: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?){ // guard let indexPath = tableView.indexPathForSelectedRow else { diff --git a/Seasonizer/CanvasViewController.swift b/Seasonizer/CanvasViewController.swift index 75d9864..ecd5be6 100644 --- a/Seasonizer/CanvasViewController.swift +++ b/Seasonizer/CanvasViewController.swift @@ -122,10 +122,17 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI // TODO: Implement `prepareForSegue(_:sender:)` to pass `allAccessories` on to `AccessoryListViewController`. // HINT: The `AccessoryListViewController` should be embedded in a `UINavigationController`: - - guard let accessoryListViewController = (segue.destinationViewController as? UINavigationController)?.topViewController as? AccessoryListViewController else { + + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?){ + // + guard let accessoryListViewController = (segue.destinationViewController as? UINavigationController)?.topViewController as? AccessoryListViewController else { return - } + } + accessoryListViewController.accessories = self.allAccessories + } + + // + // TODO: Implement an `@IBAction func unwindToCanvas(segue: UIStoryboardSegue)` Unwing Segue that the `AccessoryListViewController` can exit to. @@ -138,23 +145,19 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI // TODO: For the "selectedAccessory" segue, obtain the selected accessory and add it to the canvas. // HINTS: - - // - The `AccessoryListViewController` is the segue's `sourceViewController`: - - guard let accessoryListViewController = segue.sourceViewController as? AccessoryListViewController, + // - The `AccessoryListViewController` is the segue's `sourceViewController`: + func selectedAccessorySegue(segue: UIStoryboardSegue, sender: AccessoryListViewController?){ + guard let accessoryListViewController = segue.sourceViewController as? AccessoryListViewController, selectedAccessory = accessoryListViewController.selectedAccessory else { - return - } - - //- Create an `AccessoryView` from the `selectedAccessory` and set its initial position: - - let accessoryView = AccessoryView(accessory: selectedAccessory) - accessoryView.center = accessoryOverlayView.convertPoint(accessoryOverlayView.center, fromView: accessoryOverlayView.superview) - - //- Finally, call the `addAccessoryView(_:)` Method implemented above: - - self.addAccessoryView(accessoryView) - + return + } + //- Create an `AccessoryView` from the `selectedAccessory` and set its initial position: + let accessoryView = AccessoryView(accessory: selectedAccessory) + accessoryView.center = accessoryOverlayView.convertPoint(accessoryOverlayView.center, fromView: accessoryOverlayView.superview) + //- Finally, call the `addAccessoryView(_:)` Method implemented above: + self.addAccessoryView(accessoryView) + + } } diff --git a/Seasonizer/Main.storyboard b/Seasonizer/Main.storyboard index 3e616f4..faae628 100644 --- a/Seasonizer/Main.storyboard +++ b/Seasonizer/Main.storyboard @@ -8,23 +8,23 @@ - + - + - + - + @@ -53,16 +53,16 @@ - + - + - + @@ -79,7 +79,7 @@ - + @@ -89,17 +89,9 @@ - - - - - - - - From 402e1a11b5601097bd2ee1a7fef7da690a67dfc4 Mon Sep 17 00:00:00 2001 From: felix Date: Mon, 23 May 2016 23:14:20 +0200 Subject: [PATCH 3/5] Anzeige im CanvasViewController bleibt schwarz / kein Hinzunahme von Accessories --- Seasonizer/AccessoryListViewController.swift | 14 ++++--- Seasonizer/CanvasViewController.swift | 39 ++++++++++++-------- Seasonizer/Main.storyboard | 34 ++++++++++++++--- 3 files changed, 60 insertions(+), 27 deletions(-) diff --git a/Seasonizer/AccessoryListViewController.swift b/Seasonizer/AccessoryListViewController.swift index 2abe7a8..37b9948 100644 --- a/Seasonizer/AccessoryListViewController.swift +++ b/Seasonizer/AccessoryListViewController.swift @@ -40,15 +40,17 @@ class AccessoryListViewController: UITableViewController { // HINT: Obtain the selected index path with: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?){ // - guard let indexPath = tableView.indexPathForSelectedRow else { - return + switch segue.identifier! { + case "selectedAccessory": + guard let indexPath = tableView.indexPathForSelectedRow else { + return + } + selectedAccessory = accessories![indexPath.row] + default: + break } - selectedAccessory = accessories![indexPath.row] // } - - - } diff --git a/Seasonizer/CanvasViewController.swift b/Seasonizer/CanvasViewController.swift index ecd5be6..a978489 100644 --- a/Seasonizer/CanvasViewController.swift +++ b/Seasonizer/CanvasViewController.swift @@ -125,10 +125,15 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?){ // - guard let accessoryListViewController = (segue.destinationViewController as? UINavigationController)?.topViewController as? AccessoryListViewController else { - return + switch segue.identifier! { + case "showAccessories": + guard let accessoryListViewController = (segue.destinationViewController as? UINavigationController)?.topViewController as? AccessoryListViewController else { + break + } + accessoryListViewController.accessories = allAccessories + default: + break } - accessoryListViewController.accessories = self.allAccessories } // @@ -137,27 +142,31 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI // TODO: Implement an `@IBAction func unwindToCanvas(segue: UIStoryboardSegue)` Unwing Segue that the `AccessoryListViewController` can exit to. @IBAction func unwindToCanvas(segue: UIStoryboardSegue){ - - //no implementation + switch segue.identifier! { + case "selectedAccessory": + guard let accessoryListViewController = segue.sourceViewController as? AccessoryListViewController,selectedAccessory=accessoryListViewController.selectedAccessory else { + break + } + //- Create an `AccessoryView` from the `selectedAccessory` and set its initial position: + let accessoryView = AccessoryView(accessory: selectedAccessory) + accessoryView.center = accessoryOverlayView.convertPoint(accessoryOverlayView.center, fromView: accessoryOverlayView.superview) + //- Finally, call the `addAccessoryView(_:)` Method implemented above: + self.addAccessoryView(accessoryView) + default: + break + } } + // TODO: For the "selectedAccessory" segue, obtain the selected accessory and add it to the canvas. // HINTS: // - The `AccessoryListViewController` is the segue's `sourceViewController`: - func selectedAccessorySegue(segue: UIStoryboardSegue, sender: AccessoryListViewController?){ - guard let accessoryListViewController = segue.sourceViewController as? AccessoryListViewController, - selectedAccessory = accessoryListViewController.selectedAccessory else { - return - } + //- Create an `AccessoryView` from the `selectedAccessory` and set its initial position: - let accessoryView = AccessoryView(accessory: selectedAccessory) - accessoryView.center = accessoryOverlayView.convertPoint(accessoryOverlayView.center, fromView: accessoryOverlayView.superview) + //- Finally, call the `addAccessoryView(_:)` Method implemented above: - self.addAccessoryView(accessoryView) - - } } diff --git a/Seasonizer/Main.storyboard b/Seasonizer/Main.storyboard index faae628..8aa2f6c 100644 --- a/Seasonizer/Main.storyboard +++ b/Seasonizer/Main.storyboard @@ -15,17 +15,20 @@ - + - + + + + @@ -62,8 +65,8 @@ - - + + @@ -79,7 +82,7 @@ - + @@ -89,14 +92,33 @@ + + + + + + + + + + + + + + + + + + + - + From fdc7cd87c658c96bf0b0dbadb3e3243a90bfcf4f Mon Sep 17 00:00:00 2001 From: felix Date: Thu, 2 Jun 2016 15:42:12 +0200 Subject: [PATCH 4/5] updated --- Seasonizer/Main.storyboard | 63 +++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/Seasonizer/Main.storyboard b/Seasonizer/Main.storyboard index 8aa2f6c..5b671cd 100644 --- a/Seasonizer/Main.storyboard +++ b/Seasonizer/Main.storyboard @@ -8,17 +8,40 @@ - + + + + + - + + + + + + + + + + + - + + + + + - + + + + + + @@ -27,7 +50,8 @@ - + + @@ -76,13 +100,13 @@ - + - + @@ -92,10 +116,17 @@ - + + + + + + + + @@ -117,8 +148,18 @@ + + + + + + + + + + + + + - - - From 6854b7d5818cdff00b8fd6fb060d1642356724c2 Mon Sep 17 00:00:00 2001 From: felix Date: Mon, 6 Jun 2016 12:03:26 +0200 Subject: [PATCH 5/5] =?UTF-8?q?Constrains=5FProblem=5Fbitte=20erkl=C3=A4re?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Seasonizer/Main.storyboard | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/Seasonizer/Main.storyboard b/Seasonizer/Main.storyboard index 5b671cd..d2e8376 100644 --- a/Seasonizer/Main.storyboard +++ b/Seasonizer/Main.storyboard @@ -12,20 +12,18 @@ - + - - + + + + + - - - - - - + @@ -41,8 +39,7 @@ - - + @@ -50,8 +47,8 @@ - - + + @@ -105,8 +102,9 @@ + - + @@ -119,7 +117,7 @@ - + @@ -152,6 +150,10 @@ + + + +