Skip to content

Instantly share code, notes, and snippets.

@vagmi
Created March 2, 2016 00:58
Show Gist options
  • Save vagmi/cdb97afbe00be46c8731 to your computer and use it in GitHub Desktop.
Save vagmi/cdb97afbe00be46c8731 to your computer and use it in GitHub Desktop.
import UIKit
import React
import SnapKit
class ViewController: UIViewController {
var rootView:RCTRootView!
override func viewDidLoad() {
super.viewDidLoad()
let button = UIButton(type: .System)
button.setTitle("Refresh", forState: .Normal)
button.addTarget(self, action: "reload", forControlEvents: .TouchUpInside)
view.addSubview(button)
button.snp_makeConstraints { make in
make.top.equalTo(view.snp_top).offset(20)
make.left.equalTo(view.snp_left)
}
let codeLocation = NSURL(string: "http://localhost:8081/index.ios.bundle?platform=ios")!
rootView = RCTRootView(bundleURL: codeLocation, moduleName: "SimpleApp", initialProperties: nil, launchOptions: nil)
view.addSubview(rootView)
rootView.snp_makeConstraints { make in
make.top.equalTo(button.snp_bottom).offset(8)
make.left.equalTo(view.snp_left)
make.right.equalTo(view.snp_right)
make.bottom.equalTo(view.snp_bottom)
}
}
func reload() {
rootView.bridge.reload()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment