Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- class ViewController: CoronaViewController, CoronaViewDelegate {
- override func viewDidLoad() {
- super.viewDidLoad()
- let coronaController = CoronaViewController() // Step 1
- self.addChildViewController(coronaController) // Step 2
- let view:CoronaView = coronaController.view as! CoronaView
- view.frame = self.view.frame // Step 3
- self.view.addSubview(view) // Step 4
- view.coronaViewDelegate = self;
- view.run(); // Step 5
- let event = ["name":"nativeMessage", "phase":"loaded", "message":"Hello from Swift!"]
- view.sendEvent(event)
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- // Dispose of any resources that can be recreated.
- }
- func coronaView(_ view: CoronaView, receiveEvent event: [AnyHashable : Any]!) -> Any? {
- print("receive message: \(event["message"]!)")
- return "Nice to meet you!"
- }
- }
Add Comment
Please, Sign In to add comment