Skip to content

Instantly share code, notes, and snippets.

@dotemacs
Created November 30, 2012 10:22
Show Gist options
  • Save dotemacs/4174991 to your computer and use it in GitHub Desktop.
Save dotemacs/4174991 to your computer and use it in GitHub Desktop.
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