-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from kmcgill88/8-add-ipad-support
8 add ipad support
- Loading branch information
Showing
14 changed files
with
434 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,4 @@ Carthage | |
# `pod install` in .travis.yml | ||
# | ||
# Pods/ | ||
Example/Pods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
|
||
|
@@ -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) { | ||
|
@@ -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 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.