Guest User

ViewController.swift

a guest
Jun 28th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.91 KB | None | 0 0
  1. import UIKit
  2.  
  3. class ViewController: CoronaViewController, CoronaViewDelegate {
  4.  
  5.     override func viewDidLoad() {
  6.         super.viewDidLoad()
  7.  
  8.         let coronaController = CoronaViewController()  // Step 1
  9.         self.addChildViewController(coronaController)  // Step 2
  10.  
  11.         let view:CoronaView = coronaController.view as! CoronaView
  12.         view.frame = self.view.frame   // Step 3
  13.         self.view.addSubview(view)     // Step 4
  14.         view.coronaViewDelegate = self;
  15.         view.run();                    // Step 5
  16.  
  17.         let event = ["name":"nativeMessage", "phase":"loaded", "message":"Hello from Swift!"]
  18.         view.sendEvent(event)
  19.     }
  20.  
  21.     override func didReceiveMemoryWarning() {
  22.         super.didReceiveMemoryWarning()
  23.         // Dispose of any resources that can be recreated.
  24.     }
  25.  
  26.     func coronaView(_ view: CoronaView, receiveEvent event: [AnyHashable : Any]!) -> Any? {
  27.         print("receive message: \(event["message"]!)")
  28.         return "Nice to meet you!"
  29.     }
  30. }
Add Comment
Please, Sign In to add comment