Skip to content

Commit

Permalink
better demo
Browse files Browse the repository at this point in the history
  • Loading branch information
almassapargali committed Jul 29, 2015
1 parent 140bb61 commit 44fe8f8
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 18 deletions.
52 changes: 52 additions & 0 deletions LocationPickerDemo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,66 @@
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No location selected" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eSf-PL-I4v">
<rect key="frame" x="30" y="289" width="540" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="FZk-RA-1hh"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="O0b-J7-Fm9">
<rect key="frame" x="244" y="192" width="112" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="112" id="p7B-kX-Itn"/>
<constraint firstAttribute="height" constant="30" id="sux-pw-51R"/>
</constraints>
<state key="normal" title="Choose location">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<segue destination="6yk-tj-9ye" kind="show" identifier="LocationPicker" id="rMn-FB-8eo"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="eSf-PL-I4v" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="30" id="TMv-2m-QF0"/>
<constraint firstItem="O0b-J7-Fm9" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="128" id="boV-HZ-fBh"/>
<constraint firstAttribute="trailing" secondItem="eSf-PL-I4v" secondAttribute="trailing" constant="30" id="jZN-fK-gWr"/>
<constraint firstItem="eSf-PL-I4v" firstAttribute="top" secondItem="O0b-J7-Fm9" secondAttribute="bottom" constant="67" id="lz8-Y6-6G3"/>
<constraint firstAttribute="centerX" secondItem="O0b-J7-Fm9" secondAttribute="centerX" id="sTo-BI-W0e"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="omn-sR-iZb"/>
<connections>
<outlet property="locationNameLabel" destination="eSf-PL-I4v" id="bJm-cq-Nhm"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1057" y="306"/>
</scene>
<!--Map View Controller-->
<scene sceneID="kgk-r3-CGe">
<objects>
<viewController id="6yk-tj-9ye" customClass="MapViewController" customModule="LocationPicker" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="1RZ-F5-oIB"/>
<viewControllerLayoutGuide type="bottom" id="zgc-bj-AVo"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="y9p-Ca-sjb">
<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="Oi0-sC-0Cy" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1821" y="306"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="vGN-JP-o12">
<objects>
Expand Down
24 changes: 6 additions & 18 deletions LocationPickerDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,15 @@ import UIKit
import LocationPicker

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBOutlet weak var locationNameLabel: UILabel!

override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)

let locationPicker = MapViewController()
locationPicker.completion = { location in
if let location = location {
println(location.name)
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "LocationPicker" {
let locationPicker = segue.destinationViewController as! MapViewController
locationPicker.completion = { [weak self] location in
self?.locationNameLabel.text = flatMap(location, { $0.title }) ?? "No location selected"
}
}
navigationController?.pushViewController(locationPicker, animated: true)
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

0 comments on commit 44fe8f8

Please sign in to comment.