XCODE 8.1
을 사용하고 있습니다.
먼저 루트 viewController에서 일부 프로토콜 (대리자)을 만듭니다. 이 viewcontroller skscene을로드 할 SKView 뷰를 포함합니다.
그래서 언제든지 skscene에서 새 viewcontroller를 열고 프로토콜을 호출하기 만하면됩니다. 여기
는 mainViewcontroller에서 일부 코드 입니다 :
protocol GameProtocol {
func displayViewController()
}
.
extension MainViewController: GameProtocol {
internal func displayViewController() {
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let popoverVC = storyboard.instantiateViewController(withIdentifier: "SettingViewController") as! SettingViewController
// popoverVC.modalPresentationStyle = .fullScreen
// popoverVC.modalPresentationStyle = .popover
popoverVC.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
popoverVC.view.backgroundColor = UIColor.popBackgroundColor
popoverVC.modalPresentationStyle = .popover
popoverVC.popoverPresentationController!.delegate = self
popoverVC.popoverPresentationController!.sourceView = self.view
popoverVC.popoverPresentationController!.sourceRect = CGRect(x: 0.5, y: 0.5, width: 0, height: 0)
popoverVC.preferredContentSize = CGSize(width: self.view.frame.width, height: self.view.frame.height)
self.present(popoverVC,animated: false,completion: nil)
}
}
필자는 주 코드에이 코드를 사용하여 필요할 때 팝업 알림을 표시합니다. 게임 내에서.
및 게임 장면
func showViewController() {
let viewe = self.view as! GameSceneView
viewe.myDelegate?. displayViewController()
}
에서
는 당신이 얻을 바랍니다.