June 13th, 2012

iOS Like Facebook

by in Technology

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:@"http://m.facbook.com"]
[super viewDidLoad]
]];

; } -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{ NSURL *url = [request URL]; if([[url absoluteString] hasPrefix:@”https://m.facebook.com/home.php”]){ [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@”http://www.facebook.com/translucent.computing”]]]; } 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.

June 13th, 2012

by in Technology

⟵ Back

Leave a Reply

avatar
  Subscribe  
Notify of