-
-
Save GantMan/7025652 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 RootController < UIViewController | |
def viewDidLoad | |
super | |
@my_web_view = UIWebView.alloc.initWithFrame(view.bounds) | |
@my_web_view.delegate = self | |
@my_web_view.scalesPageToFit = FALSE | |
view.addSubview(@my_web_view) | |
@url = NSURL.URLWithString("REMOVED") | |
request = NSURLRequest.requestWithURL(@url) | |
#connection = NSURLConnection.connectionWithRequest(request, delegate: self) | |
@my_web_view.loadRequest(request) | |
end | |
def connection(connection, didReceiveAuthenticationChallenge: challenge) | |
puts "Received auth challenge" | |
cred = NSURLCredential.alloc.initWithUser("REMOVED", | |
password: "REMOVED", | |
persistence: NSURLCredentialPersistenceForSession) | |
challenge.sender.useCredential(cred, forAuthenticationChallenge: challenge) | |
end | |
def connection(connection, didReceiveResponse: response) | |
puts "didReceiveResponse" | |
@initial_data = NSMutableData.alloc.init | |
end | |
def connection(connection, didFailWithError: error) | |
puts "failed with error: #{error}" | |
end | |
def connection(connection, didReceiveData: data) | |
puts "received incremental data" | |
@initial_data.appendData data | |
end | |
def connectionDidFinishLoading(connection) | |
puts "finished loading" | |
self.view.loadData(initial_data, MIMEType: "text/html", textEncodingName: "UTF-8", baseURL: nil) | |
end | |
private | |
attr_accessor :initial_data | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment