Skip to content

Commit

Permalink
Merge pull request #9 from kmcgill88/8-add-ipad-support
Browse files Browse the repository at this point in the history
8 add ipad support
  • Loading branch information
kmcgill88 committed Jun 15, 2017
2 parents 70fc116 + ea64dfe commit 765a799
Show file tree
Hide file tree
Showing 14 changed files with 434 additions and 132 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ Carthage
# `pod install` in .travis.yml
#
# Pods/
Example/Pods
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# * http://www.objc.io/issue-6/travis-ci.html
# * https://github.com/supermarin/xcpretty#usage

osx_image: xcode7.3
language: objective-c
osx_image: xcode8.3
language: swift
# cache: cocoapods
# podfile: Example/Podfile
# before_install:
# - gem install cocoapods # Since Travis is not always on latest version
# - pod install --project-directory=Example
script:
- set -o pipefail && xcodebuild test -workspace Example/McPicker.xcworkspace -scheme McPicker-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty
- set -o pipefail && xcodebuild test -workspace Example/McPicker.xcworkspace -scheme McPicker-Example -destination 'platform=iOS Simulator,name=iPhone 7 Plus,OS=10.3.1' ONLY_ACTIVE_ARCH=NO | xcpretty
- pod lib lint
16 changes: 10 additions & 6 deletions Example/McPicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
973D169A1B9454CE644A8880 /* [CP] Copy Pods Resources */ = {
Expand Down Expand Up @@ -351,7 +351,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -443,7 +443,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -483,7 +483,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -499,11 +499,13 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = McPicker/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
Expand All @@ -515,11 +517,13 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = McPicker/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
Expand All @@ -528,8 +532,8 @@
baseConfigurationReference = ABDF864FC68406B6ADCF5DB4 /* Pods-McPicker_Tests.debug.xcconfig */;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
"$(SDKROOT)/Developer/Library/Frameworks",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand All @@ -548,8 +552,8 @@
baseConfigurationReference = 379F9F59BF461E33AB80D9F0 /* Pods-McPicker_Tests.release.xcconfig */;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
"$(SDKROOT)/Developer/Library/Frameworks",
);
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
Expand Down
28 changes: 21 additions & 7 deletions Example/McPicker/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
//
// AppDelegate.swift
// McPicker
//
// Created by Kevin McGill on 03/22/2017.
// Copyright (c) 2017 Kevin McGill. All rights reserved.
//
/*
Copyright (c) 2017 Kevin McGill <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import UIKit

Expand Down
53 changes: 45 additions & 8 deletions Example/McPicker/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="zqw-fC-zaf">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<!--Navigation Controller-->
<scene sceneID="9C1-uU-YRg">
<objects>
<navigationController id="zqw-fC-zaf" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="UPB-N4-5gx">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="vXZ-lx-hvc" kind="relationship" relationship="rootViewController" id="3zp-bD-tkW"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="UKT-nb-UPQ" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-676" y="240"/>
</scene>
<!--McPicker-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModule="McPicker_Example" customModuleProvider="target" sceneMemberID="viewController">
Expand All @@ -23,44 +39,65 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HnM-Jf-fV9">
<rect key="frame" x="140" y="28" width="96" height="30"/>
<rect key="frame" x="140" y="72" width="96" height="30"/>
<state key="normal" title="Default Picker"/>
<connections>
<action selector="showPressed:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="6xe-ey-aiJ"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a2x-VG-7p3">
<rect key="frame" x="142" y="78" width="90" height="30"/>
<rect key="frame" x="142" y="122" width="90" height="30"/>
<state key="normal" title="Styled Picker"/>
<connections>
<action selector="styledPicker:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="OSN-tI-qZs"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fEx-GG-5Tp">
<rect key="frame" x="16" y="128" width="343" height="21"/>
<rect key="frame" x="16" y="315" width="343" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="q1a-o6-gzD">
<rect key="frame" x="132" y="172" width="110" height="30"/>
<state key="normal" title="Pop Over Picker"/>
<connections>
<action selector="popOverPicker:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="jtM-7c-1mV"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="q1a-o6-gzD" firstAttribute="centerX" secondItem="a2x-VG-7p3" secondAttribute="centerX" id="0Tr-Z2-Clx"/>
<constraint firstItem="a2x-VG-7p3" firstAttribute="centerX" secondItem="fEx-GG-5Tp" secondAttribute="centerX" id="30V-vZ-BE4"/>
<constraint firstItem="fEx-GG-5Tp" firstAttribute="top" secondItem="q1a-o6-gzD" secondAttribute="bottom" constant="113" id="FaB-P5-Me3"/>
<constraint firstItem="q1a-o6-gzD" firstAttribute="top" secondItem="a2x-VG-7p3" secondAttribute="bottom" constant="20" id="Nau-eR-b9e"/>
<constraint firstItem="HnM-Jf-fV9" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" constant="8" id="RVe-GO-8tZ"/>
<constraint firstItem="fEx-GG-5Tp" firstAttribute="top" secondItem="a2x-VG-7p3" secondAttribute="bottom" constant="20" id="c7Z-cq-V7C"/>
<constraint firstItem="HnM-Jf-fV9" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="eAp-Rl-KQd"/>
<constraint firstItem="a2x-VG-7p3" firstAttribute="top" secondItem="HnM-Jf-fV9" secondAttribute="bottom" constant="20" id="gBw-qX-R5x"/>
<constraint firstAttribute="trailingMargin" secondItem="fEx-GG-5Tp" secondAttribute="trailing" id="i5v-oE-4aj"/>
<constraint firstItem="fEx-GG-5Tp" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" id="uAB-ES-Isw"/>
</constraints>
</view>
<navigationItem key="navigationItem" title="McPicker" id="fXZ-q0-BXL">
<barButtonItem key="leftBarButtonItem" title="Styled Pop Over" id="PUA-qR-42K">
<connections>
<action selector="styledPicker:" destination="vXZ-lx-hvc" id="Djt-ir-bMr"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" title="Default Pop Over" id="QJW-W1-TAp">
<connections>
<action selector="pressedBarButtonItem:" destination="vXZ-lx-hvc" id="hfh-2i-6Bt"/>
</connections>
</barButtonItem>
</navigationItem>
<connections>
<outlet property="label" destination="fEx-GG-5Tp" id="alK-q4-pWv"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-199.19999999999999" y="165.96701649175412"/>
<point key="canvasLocation" x="156" y="276"/>
</scene>
</scenes>
</document>
2 changes: 2 additions & 0 deletions Example/McPicker/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
</dict>
</plist>
97 changes: 73 additions & 24 deletions Example/McPicker/ViewController.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
//
// ViewController.swift
// McPicker
//
// Created by Kevin McGill on 03/22/2017.
// Copyright (c) 2017 Kevin McGill. All rights reserved.
//
/*
Copyright (c) 2017 Kevin McGill <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import UIKit
import McPicker

class ViewController: UIViewController {

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

let data:[[String]] = [
["Kevin", "Lauren", "Kibby", "Stella"]
]


@IBAction func showPressed(_ sender: Any) {

Expand Down Expand Up @@ -45,13 +60,11 @@ class ViewController: UIViewController {

// Short hand
//
McPicker.show(data: [["Kevin", "Lauren", "Kibby", "Stella"]], doneHandler: { selections in
// Selection(s) Made
//
McPicker.show(data: [["Kevin", "Lauren", "Kibby", "Stella"]]) { (selections:[Int : String]) -> Void in
if let name = selections[0] {
self.label.text = name
}
})
}
}

@IBAction func styledPicker(_ sender: Any) {
Expand All @@ -66,18 +79,54 @@ class ViewController: UIViewController {
["Kevin", "Lauren", "Kibby", "Stella"]
]

let picker = McPicker(data:data)
picker.label = customLabel // Set your custom label
picker.toolbarItemsFont = UIFont(name:"American Typewriter", size: 17)!
picker.toolbarButtonsColor = .white
picker.toolbarBarTintColor = .darkGray
picker.pickerBackgroundColor = .gray
let mcPicker = McPicker(data:data)
mcPicker.label = customLabel // Set your custom label
mcPicker.toolbarItemsFont = UIFont(name:"American Typewriter", size: 17)!
mcPicker.toolbarButtonsColor = .white
mcPicker.toolbarBarTintColor = .darkGray
mcPicker.pickerBackgroundColor = .gray

picker.show(doneHandler: { selections in
if let barButton = sender as? UIBarButtonItem {
// Show as Popover
//
mcPicker.showAsPopover(fromViewController: self, barButtonItem: barButton) { (selections:[Int : String]) -> Void in
if let prefix = selections[0], let name = selections[1] {
self.label.text = "\(prefix) \(name)"
}
}
} else {
// Show Normal
//
mcPicker.show() { selections in
if let prefix = selections[0], let name = selections[1] {
self.label.text = "\(prefix) \(name)"
}
}
}
}

@IBAction func popOverPicker(_ sender: UIButton) {

McPicker.showAsPopover(data:data, fromViewController: self, sourceView: sender, cancelHandler: { () -> Void in

if let prefix = selections[0], let name = selections[1] {
self.label.text = "\(prefix) \(name)"
print("Canceled Popover")

}, doneHandler: { (selections:[Int : String]) -> Void in

print("Done with Popover")
if let name = selections[0] {
self.label.text = name
}
})
}

@IBAction func pressedBarButtonItem(_ sender: UIBarButtonItem) {

McPicker.showAsPopover(data:data, fromViewController: self, barButtonItem: sender) { (selections:[Int : String]) -> Void in
print("Done with Popover")
if let name = selections[0] {
self.label.text = name
}
}
}
}
3 changes: 1 addition & 2 deletions Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ target 'McPicker_Example' do

target 'McPicker_Tests' do
inherit! :search_paths


pod 'McPicker', :path => '../'
end
end
Loading

0 comments on commit 765a799

Please sign in to comment.