mirror of
https://github.com/gimenete/iOS-boilerplate.git
synced 2026-01-10 06:58:12 -05:00
105 lines
3.2 KiB
Objective-C
105 lines
3.2 KiB
Objective-C
//
|
|
// BrowserSampleViewController.m
|
|
//
|
|
// This software is licensed under the MIT Software License
|
|
//
|
|
// Copyright (c) 2011 Nathan Buggia
|
|
// http://nathanbuggia.com/posts/browser-view-controller/
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
|
|
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
|
// the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
|
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
// SOFTWARE.
|
|
//
|
|
// Artwork generously contributed by Joseph Wain of http://glyphish.com (buy his Pro pack of icons!)
|
|
//
|
|
|
|
#import "BrowserSampleViewController.h"
|
|
|
|
@implementation BrowserSampleViewController
|
|
|
|
@synthesize webView;
|
|
@synthesize button;
|
|
@synthesize textView;
|
|
|
|
- (void)openLinkInBrowser:(id)sender
|
|
{
|
|
NSURL *url = [NSURL URLWithString:DEMO_URL];
|
|
BrowserViewController *bvc = [[BrowserViewController alloc] initWithUrls:url];
|
|
[self.navigationController pushViewController:bvc animated:YES];
|
|
[bvc release];
|
|
}
|
|
|
|
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
|
|
if ( inType == UIWebViewNavigationTypeLinkClicked ) {
|
|
[[UIApplication sharedApplication] openURL:[inRequest URL]];
|
|
return NO;
|
|
}
|
|
|
|
return YES;
|
|
}
|
|
|
|
- (void)viewDidLoad
|
|
{
|
|
[super viewDidLoad];
|
|
NSString* theHtml = [NSString stringWithFormat:@"<html><body><a href=\"%@\">%@</a></body></html>", DEMO_URL, DEMO_URL];
|
|
self.navigationItem.title = @"Examples";
|
|
[webView loadHTMLString:theHtml baseURL:nil];
|
|
|
|
[button setTitle:DEMO_URL forState:UIControlStateNormal];
|
|
|
|
[textView setText:DEMO_URL];
|
|
}
|
|
|
|
- (void)viewWillAppear:(BOOL)animated
|
|
{
|
|
[super viewWillAppear:animated];
|
|
}
|
|
|
|
- (void)viewDidAppear:(BOOL)animated
|
|
{
|
|
[super viewDidAppear:animated];
|
|
}
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated
|
|
{
|
|
[super viewWillDisappear:animated];
|
|
}
|
|
|
|
- (void)viewDidDisappear:(BOOL)animated
|
|
{
|
|
[super viewDidDisappear:animated];
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning
|
|
{
|
|
// Releases the view if it doesn't have a superview.
|
|
[super didReceiveMemoryWarning];
|
|
|
|
// Relinquish ownership any cached data, images, etc that aren't in use.
|
|
}
|
|
|
|
- (void)viewDidUnload
|
|
{
|
|
[super viewDidUnload];
|
|
|
|
// Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
|
|
// For example: self.myOutlet = nil;
|
|
}
|
|
|
|
- (void)dealloc
|
|
{
|
|
[super dealloc];
|
|
}
|
|
|
|
@end
|