Created
March 2, 2016 00:58
-
-
Save vagmi/cdb97afbe00be46c8731 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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