iOS Like Facebook

iOS Like Facebook

In the previous post we showed off the code that allowed us to login into the Facebook and like a company. Here is the iOS version. 

- (void)viewDidLoad {     
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@""]
[super viewDidLoad]

; } -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{ NSURL *url = [request URL]; if([[url absoluteString] hasPrefix:@””]){ [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@””]]]; } return YES; }
The above code loads the Facebook login screen when the controller loads. After the user logs in the code redirects to the company website. This controller has only one outlet, UIWebview. The controller also implements the UIWebViewDelegate, shouldStartLoadingWithRequest is one of the delegate methods. We also added a header to the controller with a Facebook logout button that also closes the controller.

By on June 13th, 2012 in Technology
Tags: , ,

Go back to the Blog