LoginSignup
0
0

More than 5 years have passed since last update.

AppDelegateで、ポップアップを表示するメモ。

Posted at

予め、Main.storyboardに、
ポップアップ用のHintDialoViewControllerクラスをもったViewControllerを用意しておき、
それのStoryboard IDに「idHintDialoViewController」と入れておく

image

AppDelegate.swift

// 〜 省略 〜

// 何かのコールバックでポップアップ出す等(admob動画メディエーションの視聴完了等)
func hogeCallback(){
        stampDetailPopup(hoge_int)
}

// 〜 省略 〜

// 自作ダイアログ表示
func stampDetailPopup(stampId: Int){


        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewControllerWithIdentifier("idHintDialogViewController") as! HintDialogViewController

        vc.stampId = stampId
        vc.view.alpha = 0.0

        // アニメーション
        UIView.animateWithDuration(0.3, delay: 0.0, options: .CurveEaseInOut, animations: {() -> Void in

            vc.view.alpha = 1.0 //透過度をアニメーションで変化

            }, completion: {(finished: Bool) -> Void in

        })


        // 重ねて表示
        self.window!.rootViewController?.addChildViewController(vc)
        self.window!.addSubview(vc.view!)
}

〜 省略 

これで、指定のViewControllerがポップアップで表示されるはず!

要はこれ、、、汗

self.window!.rootViewController?.addChildViewController(vc)
self.window!.addSubview(vc.view!)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0