당신은 iOS Full Screen Share Extension 거기에서 아이디어를 얻을 수 있으며,이 스위프트 3 및 스위프트 4
EntryViewController
import UIKit
@objc(EntryViewController)
class EntryViewController : UINavigationController {
override init(rootViewController: UIViewController) {
super.init(rootViewController: ShareViewController())
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.view.transform = CGAffineTransform(translationX: 0, y: self.view.frame.size.height)
UIView.animate(withDuration: 0.3, animations: {() -> Void in
self.view.transform = .identity
})
}
}
와 호환되는 아래의 코드 조각에 대한 업데이트 된 구문을 찾을 수 있습니다 ShareViewController
import UIKit
import Social
class ShareViewController: SLComposeServiceViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.white
self.navigationItem.title = "Share"
self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: Selector(("cancelButtonTapped:")))
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .save, target: self, action: Selector(("saveButtonTapped:")))
}
func saveButtonTapped(sender: UIBarButtonItem) {
self.hideExtensionWithCompletionHandler(completion: { (Bool) -> Void in
self.extensionContext!.completeRequest(returningItems: nil, completionHandler: nil)
})
}
func cancelButtonTapped(sender: UIBarButtonItem) {
self.hideExtensionWithCompletionHandler(completion: { (Bool) -> Void in
self.extensionContext!.cancelRequest(withError: NSError())
})
}
func hideExtensionWithCompletionHandler(completion: @escaping (Bool) -> Void) {
UIView.animate(withDuration: 0.3, animations: {
self.navigationController!.view.transform = CGAffineTransform(translationX: 0, y: self.navigationController!.view.frame.size.height)
}, completion: completion)
}
}
나를 위해 작동하지 않습니다. UINavigationController를로드하지만 루트가 표시되지 않습니다. –