Created
November 30, 2012 10:22
-
-
Save dotemacs/4174991 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
class AppDelegate | |
def application(application, didFinishLaunchingWithOptions:launchOptions) | |
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) | |
@window.makeKeyAndVisible | |
@window.rootViewController = RootController.new | |
@window.rootViewController.wantsFullScreenLayout = true | |
true | |
end | |
end | |
class RootController < UIViewController | |
def javaScript | |
"alert('Rubymotion');" | |
end | |
def viewDidLoad | |
super | |
view.backgroundColor = UIColor.whiteColor | |
@my_web_view = UIWebView.alloc.initWithFrame(view.bounds) | |
@my_web_view.delegate = self | |
@my_web_view.scalesPageToFit = 'YES' | |
view.addSubview(@my_web_view) | |
url = NSURL.URLWithString("http://www.rubymotion.com") | |
request = NSURLRequest.requestWithURL(url) | |
@my_web_view.loadRequest(request) | |
end | |
def webViewDidStartLoad(webView) | |
UIApplication.sharedApplication.setNetworkActivityIndicatorVisible('YES') | |
end | |
def webViewDidFinishLoad(webView) | |
UIApplication.sharedApplication.setNetworkActivityIndicatorVisible('NO') | |
webView.stringByEvaluatingJavaScriptFromString(javaScript) | |
end | |
def webView(webView, didFailLoadWithError:error) | |
UIApplication.sharedApplication.setNetworkActivityIndicatorVisible('NO') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment