Talk to an expert

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.

0 0 votes
Article Rating

June 13th, 2012

by in Technology

⟵ Back

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

0
Would love your thoughts, please comment.x
()
x