Preview clean up

This commit is contained in:
Roy Marmelstein
2016-02-14 09:18:46 +01:00
parent fd4c1c23a9
commit cc3bb46130
2 changed files with 10 additions and 9 deletions
+3 -9
View File
@@ -7,7 +7,6 @@
//
import Foundation
import QuickLook
class FileList: UIViewController, UIViewControllerPreviewingDelegate {
@@ -198,10 +197,8 @@ extension FileList: UITableViewDataSource, UITableViewDelegate {
didSelectFile(file)
}
else {
let quickLook = QLPreviewController()
previewManager.filePath = file.filePath
quickLook.dataSource = previewManager
self.navigationController?.pushViewController(quickLook, animated: true)
let filePreview = previewManager.previewViewControllerForFile(file)
self.navigationController?.pushViewController(filePreview, animated: true)
}
}
tableView.deselectRowAtIndexPath(indexPath, animated: true)
@@ -223,10 +220,7 @@ extension FileList: UITableViewDataSource, UITableViewDelegate {
if file.isDirectory {
return nil
}
let quickLook = QLPreviewController()
previewManager.filePath = file.filePath
quickLook.dataSource = previewManager
return quickLook
return previewManager.previewViewControllerForFile(file)
}
}
return nil
+7
View File
@@ -13,6 +13,13 @@ class PreviewManager: NSObject, QLPreviewControllerDataSource {
var filePath: NSURL?
func previewViewControllerForFile(file: File) -> UIViewController {
let quickLook = QLPreviewController()
quickLook.dataSource = self
self.filePath = file.filePath
return quickLook
}
func numberOfPreviewItemsInPreviewController(controller: QLPreviewController) -> Int {
return 1
}