From 76ea3e94672618ce575721fa22321e4fe3702c9d Mon Sep 17 00:00:00 2001 From: ChrisBtt Date: Thu, 12 May 2016 22:55:29 +0200 Subject: [PATCH 1/4] =?UTF-8?q?App=20l=C3=A4uft=20stabil,=20aber...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Seasonizer/AccessoryListViewController.swift | 16 +++ Seasonizer/CanvasViewController.swift | 23 ++++ Seasonizer/Main.storyboard | 121 ++++++++++++++++++- 3 files changed, 156 insertions(+), 4 deletions(-) diff --git a/Seasonizer/AccessoryListViewController.swift b/Seasonizer/AccessoryListViewController.swift index 1c32a19..f6f08b9 100644 --- a/Seasonizer/AccessoryListViewController.swift +++ b/Seasonizer/AccessoryListViewController.swift @@ -35,3 +35,19 @@ class AccessoryListViewController: UITableViewController { // MARK: - Table View Data Source // TODO: Implement the `UITableViewDataSource` protocol. +extension AccessoryListViewController { + override func numberOfSectionsInTableView(tableView: UITableView) -> Int { + return 1 + } + + override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return (accessories?.count)! + } + + override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCellWithIdentifier("AccessoryCell", forIndexPath: indexPath) as UITableViewCell + cell.imageView!.image = accessories?[indexPath.row].image + cell.textLabel!.text = accessories?[indexPath.row].title + return cell + } +} \ No newline at end of file diff --git a/Seasonizer/CanvasViewController.swift b/Seasonizer/CanvasViewController.swift index c8cebcb..7804d6a 100644 --- a/Seasonizer/CanvasViewController.swift +++ b/Seasonizer/CanvasViewController.swift @@ -120,6 +120,17 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI // TODO: Implement `prepareForSegue(_:sender:)` to pass `allAccessories` on to `AccessoryListViewController`. + + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + switch segue.identifier! { + case "AccessoryView": + guard let accessoryListViewController = (segue.destinationViewController as? UINavigationController)?.topViewController as? AccessoryListViewController else {break} + accessoryListViewController.accessories = allAccessories + + default: + break + } + } /* HINT: The `AccessoryListViewController` should be embedded in a `UINavigationController`: @@ -130,6 +141,18 @@ 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) { + switch segue.identifier! { + case "cellExitToCanvas": + print("cellExitToCanvas fired") + case "buttonExitToCanvas": + print("buttonExitToCanvas fired") + default: + break + } + print("AccessView canceled") + } + // TODO: For the "selectedAccessory" segue, obtain the selected accessory and add it to the canvas. /* diff --git a/Seasonizer/Main.storyboard b/Seasonizer/Main.storyboard index 926189e..d7a3775 100644 --- a/Seasonizer/Main.storyboard +++ b/Seasonizer/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -15,14 +15,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -44,7 +154,10 @@ - + + + + From 2e6a2add89c238a432ee95de16bd102dee797157 Mon Sep 17 00:00:00 2001 From: ChrisBtt Date: Fri, 13 May 2016 23:57:30 +0200 Subject: [PATCH 2/4] selectedAccessory fehlt noch --- Seasonizer/AccessoryListViewController.swift | 11 ++- Seasonizer/CanvasViewController.swift | 5 +- Seasonizer/Main.storyboard | 92 +++++++++----------- 3 files changed, 56 insertions(+), 52 deletions(-) diff --git a/Seasonizer/AccessoryListViewController.swift b/Seasonizer/AccessoryListViewController.swift index f6f08b9..32abcbc 100644 --- a/Seasonizer/AccessoryListViewController.swift +++ b/Seasonizer/AccessoryListViewController.swift @@ -20,6 +20,13 @@ class AccessoryListViewController: UITableViewController { // MARK: User Interaction // TODO: Implement `prepareForSegue(_:sender:)` to set `selectedAccessory` when the "selectedAccessory" Segue is performed. + + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + if segue.identifier == "AccessorySelected" { + selectedAccessory = sender!.images + } + } + /* HINT: Obtain the selected index path with: @@ -46,8 +53,8 @@ extension AccessoryListViewController { override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("AccessoryCell", forIndexPath: indexPath) as UITableViewCell - cell.imageView!.image = accessories?[indexPath.row].image - cell.textLabel!.text = accessories?[indexPath.row].title + cell.imageView!.image = accessories![indexPath.row].image + cell.textLabel!.text = accessories![indexPath.row].title return cell } } \ No newline at end of file diff --git a/Seasonizer/CanvasViewController.swift b/Seasonizer/CanvasViewController.swift index 7804d6a..35e2a00 100644 --- a/Seasonizer/CanvasViewController.swift +++ b/Seasonizer/CanvasViewController.swift @@ -126,8 +126,10 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI case "AccessoryView": guard let accessoryListViewController = (segue.destinationViewController as? UINavigationController)?.topViewController as? AccessoryListViewController else {break} accessoryListViewController.accessories = allAccessories + print(accessoryListViewController.accessories) default: + print("break") break } } @@ -143,8 +145,9 @@ 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) { switch segue.identifier! { - case "cellExitToCanvas": + case "selectedAccessory": print("cellExitToCanvas fired") + case "buttonExitToCanvas": print("buttonExitToCanvas fired") default: diff --git a/Seasonizer/Main.storyboard b/Seasonizer/Main.storyboard index d7a3775..bb44590 100644 --- a/Seasonizer/Main.storyboard +++ b/Seasonizer/Main.storyboard @@ -16,75 +16,66 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + + + + + + + + + + + + + + + + + + + - + - + + + + - + - + - + - + - - - - - - + + - + @@ -110,7 +101,13 @@ - + + + + + + + @@ -132,7 +129,7 @@ - + @@ -154,10 +151,7 @@ - + - - - From ca54530a57fac9ae4c94d1d7e43886f362e5f625 Mon Sep 17 00:00:00 2001 From: ChrisBtt Date: Sun, 15 May 2016 10:48:27 +0200 Subject: [PATCH 3/4] =?UTF-8?q?Jetzt=20l=C3=A4uft=20die=20App=20wie=20sie?= =?UTF-8?q?=20soll?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Seasonizer/AccessoryListViewController.swift | 13 +++++++++++-- Seasonizer/CanvasViewController.swift | 19 ++++++++++++++----- Seasonizer/Main.storyboard | 5 +++-- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Seasonizer/AccessoryListViewController.swift b/Seasonizer/AccessoryListViewController.swift index 32abcbc..8a51406 100644 --- a/Seasonizer/AccessoryListViewController.swift +++ b/Seasonizer/AccessoryListViewController.swift @@ -21,9 +21,12 @@ class AccessoryListViewController: UITableViewController { // TODO: Implement `prepareForSegue(_:sender:)` to set `selectedAccessory` when the "selectedAccessory" Segue is performed. + private var indexOfSelectedAccessory = 0 + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { - if segue.identifier == "AccessorySelected" { - selectedAccessory = sender!.images + if segue.identifier == "selectedAccessory" { + guard let indexPath = tableView.indexPathForSelectedRow else {return } + selectedAccessory = accessories![indexPath.row] } } @@ -43,6 +46,11 @@ class AccessoryListViewController: UITableViewController { // TODO: Implement the `UITableViewDataSource` protocol. extension AccessoryListViewController { + +// override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { +// indexOfSelectedAccessory = indexPath.row +// } + override func numberOfSectionsInTableView(tableView: UITableView) -> Int { return 1 } @@ -53,6 +61,7 @@ extension AccessoryListViewController { override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("AccessoryCell", forIndexPath: indexPath) as UITableViewCell + cell.imageView!.image = accessories![indexPath.row].image cell.textLabel!.text = accessories![indexPath.row].title return cell diff --git a/Seasonizer/CanvasViewController.swift b/Seasonizer/CanvasViewController.swift index 35e2a00..c9700cd 100644 --- a/Seasonizer/CanvasViewController.swift +++ b/Seasonizer/CanvasViewController.swift @@ -71,6 +71,10 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI UIGraphicsEndImageContext() return renderedPicture } + + +// Added + private var selectedAccessory : Accessory? // MARK: User Interaction @@ -129,7 +133,6 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI print(accessoryListViewController.accessories) default: - print("break") break } } @@ -146,14 +149,20 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI @IBAction func unwindToCanvas (segue: UIStoryboardSegue) { switch segue.identifier! { case "selectedAccessory": - print("cellExitToCanvas fired") - - case "buttonExitToCanvas": + guard let accessoryListViewController = segue.sourceViewController as? AccessoryListViewController, + selectedAccessory = accessoryListViewController.selectedAccessory else { + break + } + let accessoryView = AccessoryView(accessory: selectedAccessory) + accessoryView.center = accessoryOverlayView.convertPoint(accessoryOverlayView.center, fromView: accessoryOverlayView.superview) + + addAccessoryView(accessoryView) + + case "ExitFromButton": print("buttonExitToCanvas fired") default: break } - print("AccessView canceled") } diff --git a/Seasonizer/Main.storyboard b/Seasonizer/Main.storyboard index bb44590..9aa8f72 100644 --- a/Seasonizer/Main.storyboard +++ b/Seasonizer/Main.storyboard @@ -49,6 +49,7 @@ + @@ -91,7 +92,7 @@ - + @@ -104,7 +105,7 @@ - + From 31276a6c8ee53b5b1a99b7728194864c711f61d7 Mon Sep 17 00:00:00 2001 From: ChrisBtt Date: Wed, 18 May 2016 22:45:37 +0200 Subject: [PATCH 4/4] Jetzt funktioniert alles sagen meine Tests --- Seasonizer/Main.storyboard | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Seasonizer/Main.storyboard b/Seasonizer/Main.storyboard index 9aa8f72..ae6ee84 100644 --- a/Seasonizer/Main.storyboard +++ b/Seasonizer/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -16,8 +16,8 @@ - - + + @@ -49,8 +49,8 @@ - - + + @@ -86,7 +86,7 @@ - +