Updated GamePickerController for tvOS
This commit is contained in:
parent
7746ada490
commit
f77d16c9ce
@ -35,17 +35,23 @@ class GamePickerController: NSObject
|
||||
{
|
||||
self.presentingViewController = presentingViewController
|
||||
|
||||
#if os(iOS)
|
||||
let documentMenuController = UIDocumentMenuViewController(documentTypes: Array(Game.supportedTypeIdentifiers()), inMode: .Import)
|
||||
documentMenuController.delegate = self
|
||||
|
||||
documentMenuController.addOptionWithTitle(NSLocalizedString("iTunes", comment: ""), image: nil, order: .First, handler: self.importFromiTunes)
|
||||
|
||||
documentMenuController.addOptionWithTitle(NSLocalizedString("iTunes", comment: ""), image: nil, order: .First) { self.importFromiTunes(nil) }
|
||||
self.presentingViewController?.presentViewController(documentMenuController, animated: true, completion: nil)
|
||||
#else
|
||||
self.importFromiTunes(completion)
|
||||
#endif
|
||||
}
|
||||
|
||||
private func importFromiTunes()
|
||||
private func importFromiTunes(completion: (Void -> Void)?)
|
||||
{
|
||||
let documentsDirectoryURL = NSFileManager.defaultManager().URLsForDirectory(NSSearchPathDirectory.DocumentDirectory, inDomains: NSSearchPathDomainMask.UserDomainMask).first
|
||||
let alertController = UIAlertController(title: NSLocalizedString("Import from iTunes?", comment: ""), message: NSLocalizedString("Delta will import the games copied over via iTunes.", comment: ""), preferredStyle: .Alert)
|
||||
|
||||
let importAction = UIAlertAction(title: NSLocalizedString("Import", comment: ""), style: .Default) { action in
|
||||
|
||||
let documentsDirectoryURL = DatabaseManager.databaseDirectoryURL.URLByDeletingLastPathComponent
|
||||
|
||||
do
|
||||
{
|
||||
@ -61,6 +67,17 @@ class GamePickerController: NSObject
|
||||
}
|
||||
|
||||
self.presentingViewController?.gamePickerController = nil
|
||||
|
||||
}
|
||||
alertController.addAction(importAction)
|
||||
|
||||
let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .Cancel) { action in
|
||||
self.delegate?.gamePickerControllerDidCancel(self)
|
||||
self.presentingViewController?.gamePickerController = nil
|
||||
}
|
||||
alertController.addAction(cancelAction)
|
||||
|
||||
self.presentingViewController?.presentViewController(alertController, animated: true, completion: completion)
|
||||
}
|
||||
|
||||
private func importGamesAtURLs(URLs: [NSURL])
|
||||
@ -81,6 +98,8 @@ class GamePickerController: NSObject
|
||||
}
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
|
||||
extension GamePickerController: UIDocumentMenuDelegate
|
||||
{
|
||||
func documentMenu(documentMenu: UIDocumentMenuViewController, didPickDocumentPicker documentPicker: UIDocumentPickerViewController)
|
||||
@ -117,11 +136,13 @@ extension GamePickerController: UIDocumentPickerDelegate
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private var GamePickerControllerKey: UInt8 = 0
|
||||
|
||||
extension UIViewController
|
||||
{
|
||||
var gamePickerController: GamePickerController?
|
||||
private(set) var gamePickerController: GamePickerController?
|
||||
{
|
||||
set
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user