Skip to content
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
4 changes: 4 additions & 0 deletions PreviewControllerHideBottomButtons.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
TargetAttributes = {
C7A9FB7D1D7A0C4500579DEC = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0820;
};
};
};
Expand Down Expand Up @@ -301,6 +302,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.example.PreviewControllerHideBottomButtons;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -312,6 +314,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.example.PreviewControllerHideBottomButtons;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -334,6 +337,7 @@
C7A9FB921D7A0C4500579DEC /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
12 changes: 6 additions & 6 deletions PreviewControllerHideBottomButtons/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
Expand Down Expand Up @@ -35,6 +45,11 @@
"idiom" : "iphone",
"filename" : "Icon-60@3x.png",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -14,9 +18,9 @@
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
16 changes: 10 additions & 6 deletions PreviewControllerHideBottomButtons/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Demo Controller-->
Expand All @@ -14,11 +18,11 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zQP-3f-N4a">
<rect key="frame" x="210" y="283" width="180" height="34"/>
<rect key="frame" x="97.5" y="316.5" width="180" height="34"/>
<constraints>
<constraint firstAttribute="height" constant="34" id="zMz-of-KGn"/>
</constraints>
Expand All @@ -28,7 +32,7 @@
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="zQP-3f-N4a" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="OOb-Q0-Pys"/>
<constraint firstItem="zQP-3f-N4a" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="mo8-zt-MEG"/>
Expand Down
20 changes: 10 additions & 10 deletions PreviewControllerHideBottomButtons/DemoController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import QuickLook

class DemoController: UIViewController {

private let itemsArray:[String] = ["image1", "image2", "image3"]
fileprivate let itemsArray:[String] = ["image1", "image2", "image3"]

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -25,14 +25,14 @@ class DemoController: UIViewController {
//MARK: - IBActions
extension DemoController {

@IBAction func presentPreviewControllerTapped(sender: UIButton) {
@IBAction func presentPreviewControllerTapped(_ sender: UIButton) {

let previewController = QLPreviewController()
previewController.dataSource = self

let previewNavigationController = PreviewNavigationController(navigationBarClass:nil, toolbarClass: PreviewControllerToolbar.self)
previewNavigationController.pushViewController(previewController, animated: false)
presentViewController(previewNavigationController, animated:true, completion: nil)
present(previewNavigationController, animated:true, completion: nil)
}
}

Expand All @@ -41,17 +41,17 @@ extension DemoController {
//MARK: - QLPreviewControllerDataSource
extension DemoController : QLPreviewControllerDataSource {

func numberOfPreviewItemsInPreviewController(controller: QLPreviewController) -> Int {
func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
return itemsArray.count
}

func previewController(controller: QLPreviewController, previewItemAtIndex index: Int) -> QLPreviewItem {
func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {

guard let filePath = NSBundle.mainBundle().pathForResource(itemsArray[index], ofType:"jpg") else {
return NSURL()
guard let filePath = Bundle.main.path(forResource: itemsArray[index], ofType:"jpg") else {
return URL(fileURLWithPath: "bob") as QLPreviewItem
}

let url = NSURL.fileURLWithPath(filePath)
return url
let url = URL(fileURLWithPath: filePath)
return url as QLPreviewItem
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit

class PreviewControllerToolbar: UIToolbar {

override func setItems(items: [UIBarButtonItem]?, animated: Bool) {
override func setItems(_ items: [UIBarButtonItem]?, animated: Bool) {
super.setItems([], animated: false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class PreviewNavigationController: UINavigationController {
super.viewDidLoad()
}

override func viewWillAppear(animated: Bool) {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

if let controller = viewControllers.first {
let doneButton = UIBarButtonItem(barButtonSystemItem: .Done, target:self, action:#selector(doneButtonTapped))
let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target:self, action:#selector(doneButtonTapped))
controller.navigationItem.leftBarButtonItem = doneButton
}
}
Expand All @@ -31,7 +31,7 @@ class PreviewNavigationController: UINavigationController {

extension PreviewNavigationController {

func doneButtonTapped() -> Void {
dismissViewControllerAnimated(true, completion: nil)
@objc func doneButtonTapped() -> Void {
dismiss(animated: true, completion: nil)
}
}
}