mirror of
https://github.com/gimenete/iOS-boilerplate.git
synced 2026-01-09 14:38:04 -05:00
Added the Browser View Controller code
This commit is contained in:
@@ -75,6 +75,15 @@
|
||||
09E442D9141F9DD400AD2DAE /* SwipeableTableViewExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 09E442D7141F9DD400AD2DAE /* SwipeableTableViewExample.m */; };
|
||||
09E442DA141F9DD400AD2DAE /* SwipeableTableViewExample.xib in Resources */ = {isa = PBXBuildFile; fileRef = 09E442D8141F9DD400AD2DAE /* SwipeableTableViewExample.xib */; };
|
||||
09E442DD141F9E3600AD2DAE /* SwipeableCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 09E442DC141F9E3600AD2DAE /* SwipeableCell.m */; };
|
||||
D8EA24C4145BA49100EB08B3 /* BrowserViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D8EA24C0145BA49100EB08B3 /* BrowserViewController.m */; };
|
||||
D8EA24C5145BA49100EB08B3 /* BrowserViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D8EA24C1145BA49100EB08B3 /* BrowserViewController.xib */; };
|
||||
D8EA24C6145BA49100EB08B3 /* MyApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = D8EA24C3145BA49100EB08B3 /* MyApplication.m */; };
|
||||
D8EA24CC145BA4AC00EB08B3 /* left.png in Resources */ = {isa = PBXBuildFile; fileRef = D8EA24C8145BA4AC00EB08B3 /* left.png */; };
|
||||
D8EA24CD145BA4AC00EB08B3 /* left@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D8EA24C9145BA4AC00EB08B3 /* left@2x.png */; };
|
||||
D8EA24CE145BA4AC00EB08B3 /* right.png in Resources */ = {isa = PBXBuildFile; fileRef = D8EA24CA145BA4AC00EB08B3 /* right.png */; };
|
||||
D8EA24CF145BA4AC00EB08B3 /* right@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D8EA24CB145BA4AC00EB08B3 /* right@2x.png */; };
|
||||
D8EA24D3145BA4BC00EB08B3 /* BrowserSampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D8EA24D1145BA4BC00EB08B3 /* BrowserSampleViewController.m */; };
|
||||
D8EA24D4145BA4BC00EB08B3 /* BrowserSampleViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D8EA24D2145BA4BC00EB08B3 /* BrowserSampleViewController.xib */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -197,6 +206,18 @@
|
||||
09E442DB141F9E3600AD2DAE /* SwipeableCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SwipeableCell.h; sourceTree = "<group>"; };
|
||||
09E442DC141F9E3600AD2DAE /* SwipeableCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SwipeableCell.m; sourceTree = "<group>"; };
|
||||
C37BC8E3144C340600423D44 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
|
||||
D8EA24BF145BA49100EB08B3 /* BrowserViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BrowserViewController.h; sourceTree = "<group>"; };
|
||||
D8EA24C0145BA49100EB08B3 /* BrowserViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BrowserViewController.m; sourceTree = "<group>"; };
|
||||
D8EA24C1145BA49100EB08B3 /* BrowserViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BrowserViewController.xib; sourceTree = "<group>"; };
|
||||
D8EA24C2145BA49100EB08B3 /* MyApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyApplication.h; sourceTree = "<group>"; };
|
||||
D8EA24C3145BA49100EB08B3 /* MyApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyApplication.m; sourceTree = "<group>"; };
|
||||
D8EA24C8145BA4AC00EB08B3 /* left.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = left.png; sourceTree = "<group>"; };
|
||||
D8EA24C9145BA4AC00EB08B3 /* left@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "left@2x.png"; sourceTree = "<group>"; };
|
||||
D8EA24CA145BA4AC00EB08B3 /* right.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = right.png; sourceTree = "<group>"; };
|
||||
D8EA24CB145BA4AC00EB08B3 /* right@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "right@2x.png"; sourceTree = "<group>"; };
|
||||
D8EA24D0145BA4BC00EB08B3 /* BrowserSampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BrowserSampleViewController.h; sourceTree = "<group>"; };
|
||||
D8EA24D1145BA4BC00EB08B3 /* BrowserSampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BrowserSampleViewController.m; sourceTree = "<group>"; };
|
||||
D8EA24D2145BA4BC00EB08B3 /* BrowserSampleViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BrowserSampleViewController.xib; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -306,6 +327,7 @@
|
||||
children = (
|
||||
093EC375145B0DE90010CDBB /* AFNetworking */,
|
||||
092D3D29145AE52F002F5F6C /* AFURLCache */,
|
||||
D8EA24BD145BA45C00EB08B3 /* BrowserViewController */,
|
||||
09E442B7141F969400AD2DAE /* RefreshTableHeaderView */,
|
||||
09885F491419027D00CCE17A /* JSONKit */,
|
||||
09885F3E1418FFE000CCE17A /* SVProgressHUD */,
|
||||
@@ -356,6 +378,9 @@
|
||||
09885EF51418F48300CCE17A /* Examples */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D8EA24D0145BA4BC00EB08B3 /* BrowserSampleViewController.h */,
|
||||
D8EA24D1145BA4BC00EB08B3 /* BrowserSampleViewController.m */,
|
||||
D8EA24D2145BA4BC00EB08B3 /* BrowserSampleViewController.xib */,
|
||||
09885F391418FC6E00CCE17A /* HTTPHUDExample.h */,
|
||||
09885F3A1418FC6E00CCE17A /* HTTPHUDExample.m */,
|
||||
09885F3B1418FC6E00CCE17A /* HTTPHUDExample.xib */,
|
||||
@@ -454,6 +479,30 @@
|
||||
name = Images;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D8EA24BD145BA45C00EB08B3 /* BrowserViewController */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D8EA24BF145BA49100EB08B3 /* BrowserViewController.h */,
|
||||
D8EA24C0145BA49100EB08B3 /* BrowserViewController.m */,
|
||||
D8EA24C1145BA49100EB08B3 /* BrowserViewController.xib */,
|
||||
D8EA24C2145BA49100EB08B3 /* MyApplication.h */,
|
||||
D8EA24C3145BA49100EB08B3 /* MyApplication.m */,
|
||||
D8EA24C7145BA49900EB08B3 /* icons */,
|
||||
);
|
||||
name = BrowserViewController;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D8EA24C7145BA49900EB08B3 /* icons */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D8EA24C8145BA4AC00EB08B3 /* left.png */,
|
||||
D8EA24C9145BA4AC00EB08B3 /* left@2x.png */,
|
||||
D8EA24CA145BA4AC00EB08B3 /* right.png */,
|
||||
D8EA24CB145BA4AC00EB08B3 /* right@2x.png */,
|
||||
);
|
||||
name = icons;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
@@ -541,6 +590,12 @@
|
||||
09E442CD141F970400AD2DAE /* whiteArrow@2x.png in Resources */,
|
||||
09E442D5141F989200AD2DAE /* PullDownExample.xib in Resources */,
|
||||
09E442DA141F9DD400AD2DAE /* SwipeableTableViewExample.xib in Resources */,
|
||||
D8EA24C5145BA49100EB08B3 /* BrowserViewController.xib in Resources */,
|
||||
D8EA24CC145BA4AC00EB08B3 /* left.png in Resources */,
|
||||
D8EA24CD145BA4AC00EB08B3 /* left@2x.png in Resources */,
|
||||
D8EA24CE145BA4AC00EB08B3 /* right.png in Resources */,
|
||||
D8EA24CF145BA4AC00EB08B3 /* right@2x.png in Resources */,
|
||||
D8EA24D4145BA4BC00EB08B3 /* BrowserSampleViewController.xib in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -611,6 +666,9 @@
|
||||
093EC392145B0DE90010CDBB /* AFURLConnectionOperation.m in Sources */,
|
||||
093EC393145B0DE90010CDBB /* AFXMLRequestOperation.m in Sources */,
|
||||
093EC394145B0DE90010CDBB /* UIImageView+AFNetworking.m in Sources */,
|
||||
D8EA24C4145BA49100EB08B3 /* BrowserViewController.m in Sources */,
|
||||
D8EA24C6145BA49100EB08B3 /* MyApplication.m in Sources */,
|
||||
D8EA24D3145BA4BC00EB08B3 /* BrowserSampleViewController.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
45
IOSBoilerplate/BrowserSampleViewController.h
Normal file
45
IOSBoilerplate/BrowserSampleViewController.h
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// BrowserSampleViewController.h
|
||||
//
|
||||
// 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 <UIKit/UIKit.h>
|
||||
#import "BrowserViewController.h"
|
||||
|
||||
#define DEMO_URL @"http://nytimes.com"
|
||||
|
||||
@interface BrowserSampleViewController : UIViewController
|
||||
<UIWebViewDelegate>
|
||||
{
|
||||
IBOutlet UIWebView *webView;
|
||||
IBOutlet UIButton *button;
|
||||
IBOutlet UITextView *textView;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) UIWebView *webView;
|
||||
@property (nonatomic, retain) UIButton *button;
|
||||
@property (nonatomic, retain) UITextView *textView;
|
||||
|
||||
- (IBAction)openLinkInBrowser:(id)sender;
|
||||
|
||||
@end
|
||||
104
IOSBoilerplate/BrowserSampleViewController.m
Normal file
104
IOSBoilerplate/BrowserSampleViewController.m
Normal file
@@ -0,0 +1,104 @@
|
||||
//
|
||||
// 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
|
||||
483
IOSBoilerplate/BrowserSampleViewController.xib
Normal file
483
IOSBoilerplate/BrowserSampleViewController.xib
Normal file
@@ -0,0 +1,483 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">784</int>
|
||||
<string key="IBDocument.SystemVersion">11C74</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">1617</string>
|
||||
<string key="IBDocument.AppKitVersion">1138.23</string>
|
||||
<string key="IBDocument.HIToolboxVersion">567.00</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="NS.object.0">534</string>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>IBUIWebView</string>
|
||||
<string>IBUITextView</string>
|
||||
<string>IBUIButton</string>
|
||||
<string>IBUIView</string>
|
||||
<string>IBUILabel</string>
|
||||
<string>IBProxyObject</string>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys" id="0">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBProxyObject" id="841351856">
|
||||
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBProxyObject" id="371349661">
|
||||
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBUIView" id="565782634">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<object class="NSMutableArray" key="NSSubviews">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBUILabel" id="340821165">
|
||||
<reference key="NSNextResponder" ref="565782634"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 81}, {113, 21}}</string>
|
||||
<reference key="NSSuperview" ref="565782634"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="261297776"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:311</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClipsSubviews">YES</bool>
|
||||
<int key="IBUIContentMode">7</int>
|
||||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<string key="IBUIText">UIButton:</string>
|
||||
<object class="NSFont" key="IBUIFont" id="10778751">
|
||||
<string key="NSName">Helvetica-Bold</string>
|
||||
<double key="NSSize">17</double>
|
||||
<int key="NSfFlags">16</int>
|
||||
</object>
|
||||
<object class="NSColor" key="IBUITextColor" id="569247380">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MCAwIDAAA</bytes>
|
||||
</object>
|
||||
<nil key="IBUIHighlightedColor"/>
|
||||
<int key="IBUIBaselineAdjustment">1</int>
|
||||
<float key="IBUIMinimumFontSize">10</float>
|
||||
</object>
|
||||
<object class="IBUILabel" id="991234138">
|
||||
<reference key="NSNextResponder" ref="565782634"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 168}, {161, 21}}</string>
|
||||
<reference key="NSSuperview" ref="565782634"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="584456819"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:311</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClipsSubviews">YES</bool>
|
||||
<int key="IBUIContentMode">7</int>
|
||||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<string key="IBUIText">UITextView:</string>
|
||||
<reference key="IBUIFont" ref="10778751"/>
|
||||
<reference key="IBUITextColor" ref="569247380"/>
|
||||
<nil key="IBUIHighlightedColor"/>
|
||||
<int key="IBUIBaselineAdjustment">1</int>
|
||||
<float key="IBUIMinimumFontSize">10</float>
|
||||
</object>
|
||||
<object class="IBUILabel" id="310236656">
|
||||
<reference key="NSNextResponder" ref="565782634"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 290}, {161, 21}}</string>
|
||||
<reference key="NSSuperview" ref="565782634"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="146830956"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:311</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClipsSubviews">YES</bool>
|
||||
<int key="IBUIContentMode">7</int>
|
||||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<string key="IBUIText">UIWebView:</string>
|
||||
<reference key="IBUIFont" ref="10778751"/>
|
||||
<reference key="IBUITextColor" ref="569247380"/>
|
||||
<nil key="IBUIHighlightedColor"/>
|
||||
<int key="IBUIBaselineAdjustment">1</int>
|
||||
<float key="IBUIMinimumFontSize">10</float>
|
||||
</object>
|
||||
<object class="IBUIWebView" id="146830956">
|
||||
<reference key="NSNextResponder" ref="565782634"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 319}, {280, 77}}</string>
|
||||
<reference key="NSSuperview" ref="565782634"/>
|
||||
<reference key="NSWindow"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:667</string>
|
||||
<object class="NSColor" key="IBUIBackgroundColor" id="1024545109">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MC44MDAwMDAwMTE5IDAuODAwMDAwMDExOSAwLjgwMDAwMDAxMTkAA</bytes>
|
||||
</object>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIDataDetectorTypes">1</int>
|
||||
<bool key="IBUIDetectsPhoneNumbers">YES</bool>
|
||||
</object>
|
||||
<object class="IBUITextView" id="584456819">
|
||||
<reference key="NSNextResponder" ref="565782634"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 197}, {280, 71}}</string>
|
||||
<reference key="NSSuperview" ref="565782634"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="310236656"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:613</string>
|
||||
<reference key="IBUIBackgroundColor" ref="1024545109"/>
|
||||
<bool key="IBUIClipsSubviews">YES</bool>
|
||||
<bool key="IBUIMultipleTouchEnabled">YES</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<bool key="IBUIEditable">NO</bool>
|
||||
<string key="IBUIText"/>
|
||||
<object class="NSFont" key="IBUIFont">
|
||||
<string key="NSName">Helvetica</string>
|
||||
<double key="NSSize">17</double>
|
||||
<int key="NSfFlags">16</int>
|
||||
</object>
|
||||
<object class="IBUITextInputTraits" key="IBUITextInputTraits">
|
||||
<int key="IBUIAutocapitalizationType">2</int>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<int key="IBUIDataDetectorTypes">2</int>
|
||||
</object>
|
||||
<object class="IBUIButton" id="261297776">
|
||||
<reference key="NSNextResponder" ref="565782634"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 110}, {280, 37}}</string>
|
||||
<reference key="NSSuperview" ref="565782634"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="991234138"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:222</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIContentHorizontalAlignment">0</int>
|
||||
<int key="IBUIContentVerticalAlignment">0</int>
|
||||
<object class="NSFont" key="IBUIFont">
|
||||
<string key="NSName">Helvetica-Bold</string>
|
||||
<double key="NSSize">15</double>
|
||||
<int key="NSfFlags">16</int>
|
||||
</object>
|
||||
<int key="IBUIButtonType">1</int>
|
||||
<object class="NSColor" key="IBUIHighlightedTitleColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
</object>
|
||||
<object class="NSColor" key="IBUINormalTitleColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
|
||||
</object>
|
||||
<object class="NSColor" key="IBUINormalTitleShadowColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MC41AA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBUITextView" id="1058007266">
|
||||
<reference key="NSNextResponder" ref="565782634"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrameSize">{320, 67}</string>
|
||||
<reference key="NSSuperview" ref="565782634"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="340821165"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:613</string>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MSAxIDEAA</bytes>
|
||||
</object>
|
||||
<bool key="IBUIClipsSubviews">YES</bool>
|
||||
<bool key="IBUIMultipleTouchEnabled">YES</bool>
|
||||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<bool key="IBUIBounces">NO</bool>
|
||||
<bool key="IBUIScrollEnabled">NO</bool>
|
||||
<bool key="IBUIShowsHorizontalScrollIndicator">NO</bool>
|
||||
<bool key="IBUIShowsVerticalScrollIndicator">NO</bool>
|
||||
<bool key="IBUIEditable">NO</bool>
|
||||
<string key="IBUIText">This demonstrates how you can trap an openUrl event from each of these controls and open it in your own WebView instead of Safari</string>
|
||||
<object class="NSFont" key="IBUIFont">
|
||||
<string key="NSName">Helvetica</string>
|
||||
<double key="NSSize">14</double>
|
||||
<int key="NSfFlags">16</int>
|
||||
</object>
|
||||
<object class="IBUITextInputTraits" key="IBUITextInputTraits">
|
||||
<int key="IBUIAutocapitalizationType">2</int>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{320, 416}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="1058007266"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:180</string>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
<object class="NSColorSpace" key="NSCustomColorSpace">
|
||||
<int key="NSID">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<object class="NSMutableArray" key="connectionRecords">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">view</string>
|
||||
<reference key="source" ref="841351856"/>
|
||||
<reference key="destination" ref="565782634"/>
|
||||
</object>
|
||||
<int key="connectionID">16</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchEventConnection" key="connection">
|
||||
<string key="label">openLinkInBrowser:</string>
|
||||
<reference key="source" ref="261297776"/>
|
||||
<reference key="destination" ref="371349661"/>
|
||||
<int key="IBEventType">7</int>
|
||||
</object>
|
||||
<int key="connectionID">17</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">webView</string>
|
||||
<reference key="source" ref="841351856"/>
|
||||
<reference key="destination" ref="146830956"/>
|
||||
</object>
|
||||
<int key="connectionID">18</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">delegate</string>
|
||||
<reference key="source" ref="146830956"/>
|
||||
<reference key="destination" ref="841351856"/>
|
||||
</object>
|
||||
<int key="connectionID">20</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">button</string>
|
||||
<reference key="source" ref="841351856"/>
|
||||
<reference key="destination" ref="261297776"/>
|
||||
</object>
|
||||
<int key="connectionID">21</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">textView</string>
|
||||
<reference key="source" ref="841351856"/>
|
||||
<reference key="destination" ref="584456819"/>
|
||||
</object>
|
||||
<int key="connectionID">22</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<reference key="object" ref="0"/>
|
||||
<reference key="children" ref="1000"/>
|
||||
<nil key="parent"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-1</int>
|
||||
<reference key="object" ref="841351856"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">File's Owner</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-2</int>
|
||||
<reference key="object" ref="371349661"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">7</int>
|
||||
<reference key="object" ref="565782634"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="310236656"/>
|
||||
<reference ref="146830956"/>
|
||||
<reference ref="261297776"/>
|
||||
<reference ref="340821165"/>
|
||||
<reference ref="1058007266"/>
|
||||
<reference ref="991234138"/>
|
||||
<reference ref="584456819"/>
|
||||
</object>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">9</int>
|
||||
<reference key="object" ref="340821165"/>
|
||||
<reference key="parent" ref="565782634"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">10</int>
|
||||
<reference key="object" ref="991234138"/>
|
||||
<reference key="parent" ref="565782634"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">11</int>
|
||||
<reference key="object" ref="310236656"/>
|
||||
<reference key="parent" ref="565782634"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">12</int>
|
||||
<reference key="object" ref="146830956"/>
|
||||
<reference key="parent" ref="565782634"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">13</int>
|
||||
<reference key="object" ref="584456819"/>
|
||||
<reference key="parent" ref="565782634"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">14</int>
|
||||
<reference key="object" ref="261297776"/>
|
||||
<reference key="parent" ref="565782634"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">24</int>
|
||||
<reference key="object" ref="1058007266"/>
|
||||
<reference key="parent" ref="565782634"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>-1.CustomClassName</string>
|
||||
<string>-1.IBPluginDependency</string>
|
||||
<string>-2.CustomClassName</string>
|
||||
<string>-2.IBPluginDependency</string>
|
||||
<string>10.IBPluginDependency</string>
|
||||
<string>11.IBPluginDependency</string>
|
||||
<string>12.IBPluginDependency</string>
|
||||
<string>13.IBPluginDependency</string>
|
||||
<string>14.IBPluginDependency</string>
|
||||
<string>24.IBPluginDependency</string>
|
||||
<string>7.IBPluginDependency</string>
|
||||
<string>9.IBPluginDependency</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>BrowserSampleViewController</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>UIResponder</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="unlocalizedProperties">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference key="dict.sortedKeys" ref="0"/>
|
||||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<nil key="activeLocalization"/>
|
||||
<object class="NSMutableDictionary" key="localizations">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference key="dict.sortedKeys" ref="0"/>
|
||||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">24</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">BrowserSampleViewController</string>
|
||||
<string key="superclassName">UIViewController</string>
|
||||
<object class="NSMutableDictionary" key="actions">
|
||||
<string key="NS.key.0">openLinkInBrowser:</string>
|
||||
<string key="NS.object.0">id</string>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="actionInfosByName">
|
||||
<string key="NS.key.0">openLinkInBrowser:</string>
|
||||
<object class="IBActionInfo" key="NS.object.0">
|
||||
<string key="name">openLinkInBrowser:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="outlets">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>button</string>
|
||||
<string>textView</string>
|
||||
<string>webView</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>UIButton</string>
|
||||
<string>UITextView</string>
|
||||
<string>UIWebView</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>button</string>
|
||||
<string>textView</string>
|
||||
<string>webView</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">button</string>
|
||||
<string key="candidateClassName">UIButton</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">textView</string>
|
||||
<string key="candidateClassName">UITextView</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">webView</string>
|
||||
<string key="candidateClassName">UIWebView</string>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/BrowserSampleViewController.h</string>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
|
||||
<integer value="784" key="NS.object.0"/>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
|
||||
<integer value="3100" key="NS.object.0"/>
|
||||
</object>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
<string key="IBCocoaTouchPluginVersion">534</string>
|
||||
</data>
|
||||
</archive>
|
||||
76
IOSBoilerplate/BrowserViewController.h
Normal file
76
IOSBoilerplate/BrowserViewController.h
Normal file
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// BrowserViewController.h
|
||||
//
|
||||
// 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 <UIKit/UIKit.h>
|
||||
#import "MyApplication.h"
|
||||
|
||||
// The names of the images for the 'back' and 'forward' buttons in the toolbar.
|
||||
#define PNG_BUTTON_FORWARD @"right.png"
|
||||
#define PNG_BUTTON_BACK @"left.png"
|
||||
|
||||
// List of all strings used
|
||||
#define ACTION_CANCEL @"Cancel"
|
||||
#define ACTION_OPEN_IN_SAFARI @"Open in Safari"
|
||||
|
||||
@interface BrowserViewController : UIViewController
|
||||
<
|
||||
UIWebViewDelegate,
|
||||
UIActionSheetDelegate
|
||||
>
|
||||
{
|
||||
// the current URL of the UIWebView
|
||||
NSURL *url;
|
||||
|
||||
// the UIWebView where we render the contents of the URL
|
||||
IBOutlet UIWebView *webView;
|
||||
|
||||
// the UIToolbar with the "back" "forward" "reload" and "action" buttons
|
||||
IBOutlet UIToolbar *toolbar;
|
||||
|
||||
// used to indicate that we are downloading content from the web
|
||||
UIActivityIndicatorView *activityIndicator;
|
||||
|
||||
// pointers to the buttons on the toolbar
|
||||
UIBarButtonItem *backButton;
|
||||
UIBarButtonItem *forwardButton;
|
||||
UIBarButtonItem *stopButton;
|
||||
UIBarButtonItem *reloadButton;
|
||||
UIBarButtonItem *actionButton;
|
||||
}
|
||||
|
||||
@property(nonatomic, retain) NSURL *url;
|
||||
@property(nonatomic, retain) UIWebView *webView;
|
||||
@property(nonatomic, retain) UIToolbar *toolbar;
|
||||
@property(nonatomic, retain) UIBarButtonItem *backButton;
|
||||
@property(nonatomic, retain) UIBarButtonItem *forwardButton;
|
||||
@property(nonatomic, retain) UIBarButtonItem *stopButton;
|
||||
@property(nonatomic, retain) UIBarButtonItem *reloadButton;
|
||||
@property(nonatomic, retain) UIBarButtonItem *actionButton;
|
||||
|
||||
// Initializes the BrowserViewController with a specific URL
|
||||
- (id)initWithUrls:(NSURL*)u;
|
||||
|
||||
@end
|
||||
247
IOSBoilerplate/BrowserViewController.m
Normal file
247
IOSBoilerplate/BrowserViewController.m
Normal file
@@ -0,0 +1,247 @@
|
||||
//
|
||||
// BrowserViewController.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 "BrowserViewController.h"
|
||||
|
||||
@implementation BrowserViewController
|
||||
|
||||
@synthesize webView;
|
||||
@synthesize url;
|
||||
@synthesize toolbar;
|
||||
@synthesize forwardButton;
|
||||
@synthesize backButton;
|
||||
@synthesize stopButton;
|
||||
@synthesize reloadButton;
|
||||
@synthesize actionButton;
|
||||
|
||||
|
||||
/**********************************************************************************************************************/
|
||||
#pragma mark - UIActionSheet Delegate
|
||||
|
||||
- (void)actionSheet:(UIActionSheet *)uias clickedButtonAtIndex:(NSInteger)buttonIndex
|
||||
{
|
||||
// user pressed "Cancel"
|
||||
if(buttonIndex == [uias cancelButtonIndex]) return;
|
||||
|
||||
// user pressed "Open in Safari"
|
||||
if([[uias buttonTitleAtIndex:buttonIndex] compare:ACTION_OPEN_IN_SAFARI] == NSOrderedSame)
|
||||
{
|
||||
[(MyApplication*)[UIApplication sharedApplication] openURL:self.url forceOpenInSafari:YES];
|
||||
}
|
||||
|
||||
// TODO add your own actions here, like email the URL.
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************************************************************/
|
||||
#pragma mark - Object lifecycle
|
||||
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[webView setDelegate:nil];
|
||||
[webView release];
|
||||
[url release];
|
||||
[activityIndicator release];
|
||||
|
||||
[forwardButton release];
|
||||
[backButton release];
|
||||
[stopButton release];
|
||||
[reloadButton release];
|
||||
[actionButton release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
- (id)initWithUrls:(NSURL*)u
|
||||
{
|
||||
self = [self initWithNibName:@"BrowserViewController" bundle:nil];
|
||||
if(self)
|
||||
{
|
||||
self.webView.delegate = self;
|
||||
self.url = u;
|
||||
|
||||
activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
|
||||
|
||||
self.forwardButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:PNG_BUTTON_FORWARD]
|
||||
style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(forwardButtonPressed:)];
|
||||
|
||||
|
||||
self.backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:PNG_BUTTON_BACK]
|
||||
style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(backButtonPressed:)];
|
||||
|
||||
self.stopButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
|
||||
target:self
|
||||
action:@selector(stopReloadButtonPressed:)];
|
||||
|
||||
self.reloadButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
|
||||
target:self
|
||||
action:@selector(stopReloadButtonPressed:)];
|
||||
|
||||
self.actionButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
|
||||
target:self
|
||||
action:@selector(actionButtonPressed:)];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************/
|
||||
#pragma mark - View lifecycle
|
||||
|
||||
|
||||
- (void)updateToolbar
|
||||
{
|
||||
// toolbar
|
||||
self.forwardButton.enabled = [self.webView canGoForward];
|
||||
self.backButton.enabled = [self.webView canGoBack];
|
||||
|
||||
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
|
||||
NSMutableArray *toolbarButtons = [[NSMutableArray alloc] initWithObjects:self.backButton, flexibleSpace, self.forwardButton,
|
||||
flexibleSpace, self.reloadButton, flexibleSpace, self.actionButton, nil];
|
||||
|
||||
if([activityIndicator isAnimating]) [toolbarButtons replaceObjectAtIndex:4 withObject:self.stopButton];
|
||||
|
||||
[self.toolbar setItems:toolbarButtons animated:YES];
|
||||
[toolbarButtons release];
|
||||
[flexibleSpace release];
|
||||
|
||||
// page title
|
||||
NSString *pageTitle = [self.webView stringByEvaluatingJavaScriptFromString:@"document.title"];
|
||||
if(pageTitle) [[self navigationItem] setTitle:pageTitle];
|
||||
}
|
||||
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.webView.scalesPageToFit = YES;
|
||||
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:activityIndicator] autorelease];
|
||||
|
||||
[self.webView loadRequest:[NSURLRequest requestWithURL:self.url]];
|
||||
[self updateToolbar];
|
||||
}
|
||||
|
||||
|
||||
- (void)viewDidUnload
|
||||
{
|
||||
[[self navigationItem] setRightBarButtonItem:nil];
|
||||
[super viewDidUnload];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
return (interfaceOrientation == UIInterfaceOrientationPortrait
|
||||
|| interfaceOrientation == UIInterfaceOrientationLandscapeRight
|
||||
|| interfaceOrientation == UIInterfaceOrientationLandscapeLeft
|
||||
|| interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************************************************************/
|
||||
#pragma mark - User Interaction
|
||||
|
||||
|
||||
- (void)backButtonPressed:(id)sender
|
||||
{
|
||||
if([self.webView canGoBack]) [self.webView goBack];
|
||||
}
|
||||
|
||||
|
||||
- (void)forwardButtonPressed:(id)sender
|
||||
{
|
||||
if([self.webView canGoForward]) [self.webView goForward];
|
||||
}
|
||||
|
||||
|
||||
- (void)stopReloadButtonPressed:(id)sender
|
||||
{
|
||||
if([activityIndicator isAnimating])
|
||||
{
|
||||
[self.webView stopLoading];
|
||||
[activityIndicator stopAnimating];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:self.url];
|
||||
[self.webView loadRequest:request];
|
||||
}
|
||||
|
||||
[self updateToolbar];
|
||||
}
|
||||
|
||||
|
||||
- (void)actionButtonPressed:(id)sender
|
||||
{
|
||||
UIActionSheet *uias = [[UIActionSheet alloc] initWithTitle:nil
|
||||
delegate:self
|
||||
cancelButtonTitle:ACTION_CANCEL
|
||||
destructiveButtonTitle:nil
|
||||
otherButtonTitles:ACTION_OPEN_IN_SAFARI, nil];
|
||||
|
||||
[uias showInView:self.view];
|
||||
[uias release];
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************************************************************/
|
||||
#pragma mark - WebView Delegate
|
||||
|
||||
|
||||
- (void)webViewDidStartLoad:(UIWebView *)webView
|
||||
{
|
||||
[activityIndicator startAnimating];
|
||||
[self updateToolbar];
|
||||
}
|
||||
|
||||
|
||||
- (void)webViewDidFinishLoad:(UIWebView *)webView
|
||||
{
|
||||
if(activityIndicator) [activityIndicator stopAnimating];
|
||||
[self updateToolbar];
|
||||
}
|
||||
|
||||
|
||||
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
|
||||
{
|
||||
[self updateToolbar];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
222
IOSBoilerplate/BrowserViewController.xib
Normal file
222
IOSBoilerplate/BrowserViewController.xib
Normal file
@@ -0,0 +1,222 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1056</int>
|
||||
<string key="IBDocument.SystemVersion">11C74</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">1617</string>
|
||||
<string key="IBDocument.AppKitVersion">1138.23</string>
|
||||
<string key="IBDocument.HIToolboxVersion">567.00</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="NS.object.0">534</string>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>IBUIWebView</string>
|
||||
<string>IBUIToolbar</string>
|
||||
<string>IBUIView</string>
|
||||
<string>IBProxyObject</string>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys" id="0">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBProxyObject" id="372490531">
|
||||
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBProxyObject" id="975951072">
|
||||
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBUIView" id="191373211">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">274</int>
|
||||
<object class="NSMutableArray" key="NSSubviews">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBUIWebView" id="803439641">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">274</int>
|
||||
<string key="NSFrameSize">{320, 372}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSNextKeyView" ref="306998325"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:667</string>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MSAxIDEAA</bytes>
|
||||
</object>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIDataDetectorTypes">1</int>
|
||||
<bool key="IBUIDetectsPhoneNumbers">YES</bool>
|
||||
</object>
|
||||
<object class="IBUIToolbar" id="306998325">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">266</int>
|
||||
<string key="NSFrame">{{0, 372}, {320, 44}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:345</string>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<object class="NSMutableArray" key="IBUIItems">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrame">{{0, 64}, {320, 416}}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSNextKeyView" ref="803439641"/>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
<object class="NSColorSpace" key="NSCustomColorSpace">
|
||||
<int key="NSID">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
|
||||
<object class="IBUISimulatedNavigationBarMetrics" key="IBUISimulatedTopBarMetrics">
|
||||
<bool key="IBUIPrompted">NO</bool>
|
||||
</object>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<object class="NSMutableArray" key="connectionRecords">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">view</string>
|
||||
<reference key="source" ref="372490531"/>
|
||||
<reference key="destination" ref="191373211"/>
|
||||
</object>
|
||||
<int key="connectionID">3</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">webView</string>
|
||||
<reference key="source" ref="372490531"/>
|
||||
<reference key="destination" ref="803439641"/>
|
||||
</object>
|
||||
<int key="connectionID">5</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">delegate</string>
|
||||
<reference key="source" ref="803439641"/>
|
||||
<reference key="destination" ref="372490531"/>
|
||||
</object>
|
||||
<int key="connectionID">11</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">toolbar</string>
|
||||
<reference key="source" ref="372490531"/>
|
||||
<reference key="destination" ref="306998325"/>
|
||||
</object>
|
||||
<int key="connectionID">27</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<reference key="object" ref="0"/>
|
||||
<reference key="children" ref="1000"/>
|
||||
<nil key="parent"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">1</int>
|
||||
<reference key="object" ref="191373211"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="803439641"/>
|
||||
<reference ref="306998325"/>
|
||||
</object>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-1</int>
|
||||
<reference key="object" ref="372490531"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">File's Owner</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-2</int>
|
||||
<reference key="object" ref="975951072"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">4</int>
|
||||
<reference key="object" ref="803439641"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">6</int>
|
||||
<reference key="object" ref="306998325"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>-1.CustomClassName</string>
|
||||
<string>-1.IBPluginDependency</string>
|
||||
<string>-2.CustomClassName</string>
|
||||
<string>-2.IBPluginDependency</string>
|
||||
<string>1.IBPluginDependency</string>
|
||||
<string>4.IBPluginDependency</string>
|
||||
<string>6.IBPluginDependency</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>WebViewController</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>UIResponder</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="unlocalizedProperties">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference key="dict.sortedKeys" ref="0"/>
|
||||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<nil key="activeLocalization"/>
|
||||
<object class="NSMutableDictionary" key="localizations">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference key="dict.sortedKeys" ref="0"/>
|
||||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">27</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes"/>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
|
||||
<integer value="3000" key="NS.object.0"/>
|
||||
</object>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
<string key="IBCocoaTouchPluginVersion">534</string>
|
||||
</data>
|
||||
</archive>
|
||||
@@ -36,4 +36,6 @@
|
||||
|
||||
+ (IOSBoilerplateAppDelegate*) sharedAppDelegate;
|
||||
|
||||
- (BOOL)openURL:(NSURL*)url;
|
||||
|
||||
@end
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#import "IOSBoilerplateAppDelegate.h"
|
||||
#import "ImageManager.h"
|
||||
#import "AFURLCache.h"
|
||||
#import "BrowserViewController.h"
|
||||
|
||||
@implementation IOSBoilerplateAppDelegate
|
||||
|
||||
@@ -39,6 +40,15 @@
|
||||
return (IOSBoilerplateAppDelegate*) [UIApplication sharedApplication].delegate;
|
||||
}
|
||||
|
||||
- (BOOL)openURL:(NSURL*)url
|
||||
{
|
||||
BrowserViewController *bvc = [[BrowserViewController alloc] initWithUrls:url];
|
||||
[self.navigationController pushViewController:bvc animated:YES];
|
||||
[bvc release];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
// use custom URLCache to get disk caching on iOS
|
||||
|
||||
37
IOSBoilerplate/MyApplication.h
Normal file
37
IOSBoilerplate/MyApplication.h
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// MyApplication.h
|
||||
//
|
||||
// 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 <UIKit/UIKit.h>
|
||||
#import "IOSBoilerplateAppDelegate.h"
|
||||
|
||||
|
||||
@interface MyApplication : UIApplication
|
||||
|
||||
-(BOOL)openURL:(NSURL *)url;
|
||||
|
||||
-(BOOL)openURL:(NSURL *)url forceOpenInSafari:(BOOL)forceOpenInSafari;
|
||||
|
||||
@end
|
||||
76
IOSBoilerplate/MyApplication.m
Normal file
76
IOSBoilerplate/MyApplication.m
Normal file
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// MyApplication.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 "MyApplication.h"
|
||||
|
||||
@implementation MyApplication
|
||||
|
||||
|
||||
- (BOOL)openURL:(NSURL *)url
|
||||
{
|
||||
return [self openURL:url forceOpenInSafari:NO];
|
||||
}
|
||||
|
||||
|
||||
-(BOOL)openURL:(NSURL *)url forceOpenInSafari:(BOOL)forceOpenInSafari
|
||||
{
|
||||
if(forceOpenInSafari)
|
||||
{
|
||||
// We're overriding our app trying to open this URL, so we'll let UIApplication federate this request back out
|
||||
// through the normal channels. The return value states whether or not they were able to open the URL.
|
||||
return [super openURL:url];
|
||||
}
|
||||
|
||||
//
|
||||
// Otherwise, we'll see if it is a request that we should let our app open.
|
||||
|
||||
BOOL couldWeOpenUrl = NO;
|
||||
|
||||
NSString* scheme = [url.scheme lowercaseString];
|
||||
if([scheme compare:@"http"] == NSOrderedSame
|
||||
|| [scheme compare:@"https"] == NSOrderedSame)
|
||||
{
|
||||
// TODO - Here you might also want to check for other conditions where you do not want your app opening URLs (e.g.
|
||||
// Facebook authentication requests, OAUTH requests, etc)
|
||||
|
||||
// TODO - Update the cast below with the name of your AppDelegate
|
||||
// Let's call the method you wrote on your AppDelegate to actually open the BrowserViewController
|
||||
// NATE
|
||||
couldWeOpenUrl = [(IOSBoilerplateAppDelegate*)self.delegate openURL:url];
|
||||
}
|
||||
|
||||
if(!couldWeOpenUrl)
|
||||
{
|
||||
return [super openURL:url];
|
||||
}
|
||||
else
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -35,6 +35,7 @@
|
||||
#import "AutocompleteLocationExample.h"
|
||||
#import "PullDownExample.h"
|
||||
#import "SwipeableTableViewExample.h"
|
||||
#import "BrowserSampleViewController.h"
|
||||
|
||||
@implementation RootViewController
|
||||
|
||||
@@ -72,7 +73,7 @@
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return 3;
|
||||
return 4;
|
||||
}
|
||||
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
|
||||
@@ -89,6 +90,10 @@
|
||||
return @"Maps & locations";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
return @"Web Browser";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -110,6 +115,10 @@
|
||||
return 2;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
return 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -178,6 +187,16 @@
|
||||
cell.detailTextLabel.text = @"Uses the Google Maps API to search locations";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (indexPath.section == 3) {
|
||||
switch (indexPath.row) {
|
||||
case 0:
|
||||
cell.textLabel.text = @"Web Browser integration";
|
||||
cell.detailTextLabel.text = @"Open URLs from UITextViews, UIWebViews, UITableViews, and UIButtons";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -236,12 +255,20 @@
|
||||
vc = [[AutocompleteLocationExample alloc] init];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (indexPath.section == 3) {
|
||||
switch (indexPath.row) {
|
||||
case 0:
|
||||
vc = [[BrowserSampleViewController alloc] init];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (vc) {
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
[vc release];
|
||||
|
||||
BIN
IOSBoilerplate/left.png
Normal file
BIN
IOSBoilerplate/left.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 200 B |
BIN
IOSBoilerplate/left@2x.png
Normal file
BIN
IOSBoilerplate/left@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 313 B |
@@ -11,7 +11,7 @@
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
int retVal = UIApplicationMain(argc, argv, nil, nil);
|
||||
int retVal = UIApplicationMain(argc, argv, @"MyApplication", nil);
|
||||
[pool release];
|
||||
return retVal;
|
||||
}
|
||||
|
||||
BIN
IOSBoilerplate/right.png
Normal file
BIN
IOSBoilerplate/right.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 201 B |
BIN
IOSBoilerplate/right@2x.png
Normal file
BIN
IOSBoilerplate/right@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 303 B |
Reference in New Issue
Block a user