Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seasonizer; Frage/Problem bzgl. declaration compiler error #8

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions Seasonizer/AccessoryListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,45 @@ class AccessoryListViewController: UITableViewController {

// MARK: User Interaction



//
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
// TODO: Implement `prepareForSegue(_:sender:)` to set `selectedAccessory` when the "selectedAccessory" Segue is performed.
/*
HINT: Obtain the selected index path with:

guard let indexPath = tableView.indexPathForSelectedRow else {
return
// HINT: Obtain the selected index path with:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?){
//
switch segue.identifier! {
case "selectedAccessory":
guard let indexPath = tableView.indexPathForSelectedRow else {
return
}
selectedAccessory = accessories![indexPath.row]
default:
break
}

*/

//
}
}


// MARK: - Table View Data Source





// TODO: Implement the `UITableViewDataSource` protocol.
65 changes: 40 additions & 25 deletions Seasonizer/CanvasViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down Expand Up @@ -120,38 +121,52 @@ 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 {
return
}
*/
// HINT: The `AccessoryListViewController` should be embedded in a `UINavigationController`:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?){
//
switch segue.identifier! {
case "showAccessories":
guard let accessoryListViewController = (segue.destinationViewController as? UINavigationController)?.topViewController as? AccessoryListViewController else {
break
}
accessoryListViewController.accessories = allAccessories
default:
break
}
}

//



// 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 "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`:

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)

// HINTS:
// - The `AccessoryListViewController` is the segue's `sourceViewController`:

- Finally, call the `addAccessoryView(_:)` Method implemented above:

self.addAccessoryView(accessoryView)
*/
//- Create an `AccessoryView` from the `selectedAccessory` and set its initial position:

//- Finally, call the `addAccessoryView(_:)` Method implemented above:
}


Expand Down
139 changes: 128 additions & 11 deletions Seasonizer/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,24 +1,55 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="A6u-BR-TcU">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="A6u-BR-TcU">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--Seasonizer-->
<!--CanvasViewController-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController storyboardIdentifier="canvasViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="BYZ-38-t0r" customClass="CanvasViewController" customModule="Seasonizer" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="canvasViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="BYZ-38-t0r" userLabel="CanvasViewController" customClass="CanvasViewController" customModule="Seasonizer" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
<viewControllerLayoutGuide type="top" id="j11-oF-3d1"/>
<viewControllerLayoutGuide type="bottom" id="vFI-5U-Dja"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<stackView key="view" opaque="NO" contentMode="scaleAspectFill" axis="vertical" alignment="center" id="yim-oF-JRC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<toolbarItems/>
<navigationItem key="navigationItem" title="Seasonizer" id="6dS-Kq-rKs"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ZeZ-l4-euA">
<rect key="frame" x="0.0" y="0.0" width="600" height="300"/>
</imageView>
<imageView opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="c9C-MA-pbB" customClass="AccessoryView" customModule="Seasonizer" customModuleProvider="target">
<rect key="frame" x="0.0" y="300" width="600" height="300"/>
</imageView>
</subviews>
</stackView>
<toolbarItems>
<barButtonItem systemItem="trash" id="UGS-a5-QZC">
<connections>
<action selector="trashButtonPressed:" destination="BYZ-38-t0r" id="4Q1-LO-zPl"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="PNv-Lk-jmc"/>
<barButtonItem style="plain" systemItem="camera" id="C03-xJ-485">
<connections>
<action selector="cameraButtonPressed:" destination="BYZ-38-t0r" id="34T-8i-TOH"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="KFn-7B-Ycw"/>
<barButtonItem systemItem="add" id="MCP-VG-csn">
<connections>
<segue destination="l0j-Jk-Wi4" kind="show" identifier="showAccessories" id="VlK-uq-LI1"/>
</connections>
</barButtonItem>
</toolbarItems>
<navigationItem key="navigationItem" title="Seasonizer" id="6dS-Kq-rKs">
<barButtonItem key="rightBarButtonItem" style="done" systemItem="action" id="Lv5-69-wgh"/>
</navigationItem>
<connections>
<outlet property="accessoryOverlayView" destination="c9C-MA-pbB" id="f96-wV-2yF"/>
<outlet property="photoImageView" destination="ZeZ-l4-euA" id="m2F-ri-Tva"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
Expand Down Expand Up @@ -46,5 +77,91 @@
</objects>
<point key="canvasLocation" x="258" y="136"/>
</scene>
<!--Accessories-->
<scene sceneID="DAA-8p-llE">
<objects>
<tableViewController title="Accessories" id="VXu-Ca-aOL" customClass="AccessoryListViewController" customModule="Seasonizer" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="M2H-BI-WIP">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="accessoryCell" textLabel="VKb-Gz-efo" style="IBUITableViewCellStyleDefault" id="I6C-rf-Ab7">
<rect key="frame" x="0.0" y="92" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="I6C-rf-Ab7" id="u4K-gW-jXs">
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="VKb-Gz-efo">
<rect key="frame" x="15" y="0.0" width="570" height="43"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<accessibility key="accessibilityConfiguration" identifier="accessoryCell"/>
<connections>
<segue destination="q2O-zk-cbG" kind="unwind" identifier="selectedAccessory" unwindAction="unwindToCanvas:" id="bfC-h3-DHg"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="VXu-Ca-aOL" id="frf-BL-VVz"/>
<outlet property="delegate" destination="VXu-Ca-aOL" id="psx-Sm-vca"/>
</connections>
</tableView>
<toolbarItems/>
<navigationItem key="navigationItem" id="JWg-Ji-58G">
<barButtonItem key="leftBarButtonItem" title="Cancel" id="fiD-qb-F4s">
<connections>
<segue destination="q2O-zk-cbG" kind="unwind" unwindAction="unwindToCanvas:" id="WxM-WN-Nce"/>
</connections>
</barButtonItem>
</navigationItem>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="MAa-Sb-wIM" userLabel="First Responder" sceneMemberID="firstResponder"/>
<exit id="q2O-zk-cbG" userLabel="Exit" sceneMemberID="exit"/>
</objects>
<point key="canvasLocation" x="1091" y="902"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="qXz-DV-fXM">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="l0j-Jk-Wi4" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="dIR-QG-Q5S">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="VXu-Ca-aOL" kind="relationship" relationship="rootViewController" id="Eqq-16-MVh"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="4A9-cZ-o6X" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="279" y="902"/>
</scene>
<!--View Controller-->
<scene sceneID="eFi-XO-sls">
<objects>
<viewController id="khW-Bz-6XS" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="WbX-nR-Che"/>
<viewControllerLayoutGuide type="bottom" id="epb-rl-xdw"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kug-8H-3uk">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="HdU-t1-3Xq" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>