From f8b0bbac55c06a620ffdc2059571ccdf9302d5d4 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 15 May 2016 13:07:25 +0200 Subject: [PATCH 1/3] Problem mit dem Bewegen von Accessoires Ich kann die Accessoires auf meinem Bild nicht bewegen --- Seasonizer.xcodeproj/project.pbxproj | 8 +- Seasonizer/AccessoryListViewController.swift | 28 ++++- Seasonizer/CanvasViewController.swift | 29 ++++- Seasonizer/Main.storyboard | 117 ++++++++++++++++++- 4 files changed, 171 insertions(+), 11 deletions(-) mode change 100644 => 100755 Seasonizer/Main.storyboard diff --git a/Seasonizer.xcodeproj/project.pbxproj b/Seasonizer.xcodeproj/project.pbxproj index 76740c0..710a235 100644 --- a/Seasonizer.xcodeproj/project.pbxproj +++ b/Seasonizer.xcodeproj/project.pbxproj @@ -277,9 +277,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; INFOPLIST_FILE = Seasonizer/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "de.uni-heidelberg.ios-dev-kurs.seasonizer"; + PRODUCT_BUNDLE_IDENTIFIER = "de.uni-heidelberg.ios-dev-kurs.colin.seasonizer"; PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -289,9 +291,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; INFOPLIST_FILE = Seasonizer/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "de.uni-heidelberg.ios-dev-kurs.seasonizer"; + PRODUCT_BUNDLE_IDENTIFIER = "de.uni-heidelberg.ios-dev-kurs.colin.seasonizer"; PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; diff --git a/Seasonizer/AccessoryListViewController.swift b/Seasonizer/AccessoryListViewController.swift index 1c32a19..3bc3b30 100644 --- a/Seasonizer/AccessoryListViewController.swift +++ b/Seasonizer/AccessoryListViewController.swift @@ -16,7 +16,15 @@ class AccessoryListViewController: UITableViewController { var accessories: [Accessory]? var selectedAccessory: Accessory? + private var indexOfSelectedAccessory = 0 + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + if segue.identifier == "selectedAccessory" { + guard let indexPath = tableView.indexPathForSelectedRow else {return } + selectedAccessory = accessories![indexPath.row] + } + } + // MARK: User Interaction // TODO: Implement `prepareForSegue(_:sender:)` to set `selectedAccessory` when the "selectedAccessory" Segue is performed. @@ -28,10 +36,24 @@ class AccessoryListViewController: UITableViewController { } */ - -} - + // MARK: - Table View Data Source // TODO: Implement the `UITableViewDataSource` protocol. + 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..6ef0316 100644 --- a/Seasonizer/CanvasViewController.swift +++ b/Seasonizer/CanvasViewController.swift @@ -25,7 +25,6 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI /// Eine View, die _über_ der `photoImageView` positioniert ist und die Accessories anzeigt. @IBOutlet weak var accessoryOverlayView: UIView! - // MARK: Accessory Handling /// Displays the accessory view on the canvas and enables user interaction with it. @@ -72,6 +71,7 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI return renderedPicture } + var selectedAccessory : Accessory? // MARK: User Interaction @@ -118,6 +118,15 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI self.presentViewController(activityViewController, animated: true, completion: nil) } + 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 + } + } // TODO: Implement `prepareForSegue(_:sender:)` to pass `allAccessories` on to `AccessoryListViewController`. /* @@ -128,7 +137,6 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI } */ - // TODO: Implement an `@IBAction func unwindToCanvas(segue: UIStoryboardSegue)` Unwing Segue that the `AccessoryListViewController` can exit to. // TODO: For the "selectedAccessory" segue, obtain the selected accessory and add it to the canvas. @@ -151,6 +159,23 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI self.addAccessoryView(accessoryView) */ + + @IBAction func unwindToCanvas (segue: UIStoryboardSegue) { + switch segue.identifier! { + case "selectedAccessory": + 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": + break + default: + break + } + } } diff --git a/Seasonizer/Main.storyboard b/Seasonizer/Main.storyboard old mode 100644 new mode 100755 index 926189e..ae77eed --- a/Seasonizer/Main.storyboard +++ b/Seasonizer/Main.storyboard @@ -1,6 +1,7 @@ + @@ -15,14 +16,122 @@ + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -44,7 +153,7 @@ - + From 1304dde803bdda0876943e68257a7bd8bd9f754c Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 22 May 2016 11:47:36 +0200 Subject: [PATCH 2/3] jetzt funktionierst :) --- Seasonizer.xcodeproj/project.pbxproj | 5 +++++ Seasonizer/Main.storyboard | 29 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Seasonizer.xcodeproj/project.pbxproj b/Seasonizer.xcodeproj/project.pbxproj index 710a235..6bba915 100644 --- a/Seasonizer.xcodeproj/project.pbxproj +++ b/Seasonizer.xcodeproj/project.pbxproj @@ -138,6 +138,7 @@ TargetAttributes = { 87549C3E1B34067200CD1868 = { CreatedOnToolsVersion = 6.3.2; + DevelopmentTeam = LS389VJ9WF; }; }; }; @@ -276,11 +277,13 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; INFOPLIST_FILE = Seasonizer/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "de.uni-heidelberg.ios-dev-kurs.colin.seasonizer"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -290,11 +293,13 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; INFOPLIST_FILE = Seasonizer/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "de.uni-heidelberg.ios-dev-kurs.colin.seasonizer"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/Seasonizer/Main.storyboard b/Seasonizer/Main.storyboard index ae77eed..a9e716a 100755 --- a/Seasonizer/Main.storyboard +++ b/Seasonizer/Main.storyboard @@ -18,10 +18,20 @@ - + + + + + + + + + + + @@ -50,7 +60,7 @@ - + @@ -58,7 +68,7 @@ - + @@ -66,18 +76,9 @@ - - - - - - - - - - + @@ -103,7 +104,7 @@ - + From 6d4c4cc0dd983c6be41922a85c4974bfbe8d89d4 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 11 Jun 2016 21:04:18 +0200 Subject: [PATCH 3/3] Update Auto Layout Constraints --- Seasonizer/Main.storyboard | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Seasonizer/Main.storyboard b/Seasonizer/Main.storyboard index a9e716a..79e01ab 100755 --- a/Seasonizer/Main.storyboard +++ b/Seasonizer/Main.storyboard @@ -3,6 +3,7 @@ + @@ -17,7 +18,7 @@ - + @@ -27,10 +28,14 @@ - - - - + + + + + + + + @@ -88,7 +93,7 @@ - +