How many lines of code do you have to write for displaying a webpage ‘in-app”.
3 methinks.
Wouldn’t be great if there is a built in class for presenting a webpage using “presentModalViewController”? Meet MKWebViewController.
Step 1:
Drop the attached three files into your project and write the following three lines on your action callback (buttonDidTap) or equivalent methods
MKWebViewController *controller = [[[MKWebViewController alloc] initWithNibName:@"MKWebViewController" bundle:nil] autorelease]; controller.url = @"http://blog.mugunthkumar.com"; [self presentModalViewController:controller animated:YES];
Step 2:
Nah, no step 2.
That’s it. On landscape mode, the controller even rotates and hides the toolbar. On portrait mode it brings back the toolbar and provides you a close button. The controller automatically handles any errors, and displays appropriate error messages, close the window when the user taps on the “Dismiss” button on the error message. What more, the controller can also display any iOS supported file format that includes, PDF, Office, iWork documents.
Give it a try, and do let me know your feedback.
Source Code
MKWebViewController.zip
–
Mugunth
Follow me on Twitter
Related posts:
- iOS Tip: Display Names in iPhone Display Order If you have noticed the contacts app on your iPhone/iPad,...
- In App Purchases: Troubleshooting Code=0 “Cannot connect to iTunes Store” (SKErrorUnknown) When using MKStoreKit or any other equivalent framework or regular...
- iOS Control: MKHorizMenu Ok, I’m getting a bit aggressive here. I just finished...
- iOS Tutorial: Sending In App Tweets In iOS 5, Apple introduced tighter twitter integration with Twitter.framework...
-
Raj
-
Anonymous
-
Anonymous
-
http://meachware.com Meachware
