├── snapshot.png ├── THWebViewControllerExample ├── THWebViewControllerExample │ ├── en.lproj │ │ ├── InfoPlist.strings │ │ ├── MainStoryboard_iPhone.storyboard │ │ └── MainStoryboard_iPad.storyboard │ ├── EXViewController.h │ ├── EXAppDelegate.h │ ├── THWebViewControllerExample-Prefix.pch │ ├── main.m │ ├── THWebViewControllerExample-Info.plist │ ├── EXViewController.m │ └── EXAppDelegate.m └── THWebViewControllerExample.xcodeproj │ ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── tokuhirom.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ ├── xcuserdata │ └── tokuhirom.xcuserdatad │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── THWebViewControllerExample.xcscheme │ └── project.pbxproj ├── THWebViewController ├── THWebController.bundle │ └── gfx │ │ ├── backIcon.png │ │ ├── backIcon@2x.png │ │ ├── forwardIcon.png │ │ └── forwardIcon@2x.png ├── THWebController.h └── THWebController.m ├── .gitignore ├── THWebViewController.podspec ├── README.mkdn └── LICENSE /snapshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokuhirom/THWebViewController/HEAD/snapshot.png -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /THWebViewController/THWebController.bundle/gfx/backIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokuhirom/THWebViewController/HEAD/THWebViewController/THWebController.bundle/gfx/backIcon.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.xcodeproj/* 2 | !*.xcodeproj/project.pbxproj 3 | build 4 | .DS_Store 5 | ._* 6 | .svn 7 | *.xcworkspace 8 | Pods 9 | Podfile.lock 10 | Podfile.bak 11 | *.xcuserdatad 12 | -------------------------------------------------------------------------------- /THWebViewController/THWebController.bundle/gfx/backIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokuhirom/THWebViewController/HEAD/THWebViewController/THWebController.bundle/gfx/backIcon@2x.png -------------------------------------------------------------------------------- /THWebViewController/THWebController.bundle/gfx/forwardIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokuhirom/THWebViewController/HEAD/THWebViewController/THWebController.bundle/gfx/forwardIcon.png -------------------------------------------------------------------------------- /THWebViewController/THWebController.bundle/gfx/forwardIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokuhirom/THWebViewController/HEAD/THWebViewController/THWebController.bundle/gfx/forwardIcon@2x.png -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample.xcodeproj/project.xcworkspace/xcuserdata/tokuhirom.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokuhirom/THWebViewController/HEAD/THWebViewControllerExample/THWebViewControllerExample.xcodeproj/project.xcworkspace/xcuserdata/tokuhirom.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample/EXViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // EXViewController.h 3 | // THWebViewControllerExample 4 | // 5 | // Created by 松野 トクヒロ on 12/01/07. 6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface EXViewController : UIViewController 12 | 13 | - (IBAction)openURL:(id)sender; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample/EXAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // EXAppDelegate.h 3 | // THWebViewControllerExample 4 | // 5 | // Created by 松野 トクヒロ on 12/01/07. 6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface EXAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample/THWebViewControllerExample-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'THWebViewControllerExample' target in the 'THWebViewControllerExample' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_5_0 8 | #warning "This project uses features only available in iOS SDK 5.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // THWebViewControllerExample 4 | // 5 | // Created by 松野 トクヒロ on 12/01/07. 6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "EXAppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([EXAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /THWebViewController.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "THWebViewController" 3 | s.version = "0.0.1" 4 | s.summary = "Minimalistic WebViewController" 5 | s.homepage = "https://github.com/tokuhirom/THWebViewController" 6 | s.license = { :type => 'MIT', :file => 'LICENSE' } 7 | s.author = "Tokuhiro Matsuno" 8 | s.platform = :ios, '5.0' 9 | s.source = { :git => "https://github.com/tokuhirom/THWebViewController.git", :commit => "113abd404adb42f32741f9f97f3b6cebb6974c84" } 10 | s.source_files = 'THWebViewController/*.{h,m}' 11 | s.resource = "THWebViewController/THWebController.bundle" 12 | s.requires_arc = true 13 | end 14 | -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample.xcodeproj/xcuserdata/tokuhirom.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | THWebViewControllerExample.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | A811803614B808BF00FEADDD 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /README.mkdn: -------------------------------------------------------------------------------- 1 | THWebViewController - Tiny implementation of WebViewController 2 | ============================================================== 3 | 4 | ![Snapshot](https://github.com/tokuhirom/THWebViewController/raw/master/snapshot.png) 5 | 6 | DESCRIPTION 7 | ----------- 8 | 9 | This is a tiny library for iOS(iPhone/iPad). 10 | This library only provides one class named THWebViewController. 11 | So it's same as TTWebViewController and NIWebViewController. 12 | Yes, THWebViewController is forked from NIWebViewController. 13 | 14 | You can drop in 1 header, 1 code, 1 bundles, that's all. 15 | Very easy. 16 | 17 | I don't like large application frameworks for iOS application. 18 | Since I'm minimalist. 19 | 20 | SYNOPSIS 21 | -------- 22 | 23 | THWebViewController * webController = [[THWebViewController alloc] init]; 24 | [webController openURL:[NSURL URLWithString:@"http://tou.ch/"]]; 25 | [self.navigationController pushViewController:webController 26 | animated:YES]; 27 | 28 | DEPENDENCIES 29 | ------------ 30 | 31 | There is no dependencies. 32 | 33 | SUBCLASSING 34 | ----------- 35 | 36 | THWebViewController supports subclassing. 37 | 38 | THWebViewController is UIViewController < UIWebViewDelegate, UIActionSheetDelegate >. 39 | 40 | You can override following methods in your subclass. 41 | 42 | * UIWebViewDelegate 43 | * - webView:shouldStartLoadWithRequest:navigationType: 44 | * - webViewDidStartLoad: 45 | * - webViewDidFinishLoad: 46 | * - webView:didFailLoadWithError: 47 | * UIActionSheetDelegate 48 | * - actionSheet:clickedButtonAtIndex: 49 | * - actionSheet:didDismissWithButtonIndex: 50 | 51 | CREDITS 52 | ------- 53 | 54 | 55 | LICENSE 56 | ------- 57 | 58 | Apache License(Same as nimbus, three20) 59 | For more details, please read LICENSE file. 60 | 61 | -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample/THWebViewControllerExample-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFiles 12 | 13 | CFBundleIdentifier 14 | org.64p.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | UIMainStoryboardFile 30 | MainStoryboard_iPhone 31 | UIMainStoryboardFile~ipad 32 | MainStoryboard_iPad 33 | UIRequiredDeviceCapabilities 34 | 35 | armv7 36 | 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationLandscapeLeft 41 | UIInterfaceOrientationLandscapeRight 42 | 43 | UISupportedInterfaceOrientations~ipad 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationPortraitUpsideDown 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample/EXViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // EXViewController.m 3 | // THWebViewControllerExample 4 | // 5 | // Created by 松野 トクヒロ on 12/01/07. 6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "EXViewController.h" 10 | #import "THWebController.h" 11 | 12 | @implementation EXViewController 13 | 14 | - (void)didReceiveMemoryWarning 15 | { 16 | [super didReceiveMemoryWarning]; 17 | // Release any cached data, images, etc that aren't in use. 18 | } 19 | 20 | - (IBAction)openURL:(id)sender { 21 | THWebController *webController = [[THWebController alloc] init]; 22 | [webController openURL:[NSURL URLWithString:@"http://livedoor.com/"]]; 23 | [self.navigationController pushViewController:webController animated:YES]; 24 | } 25 | 26 | 27 | #pragma mark - View lifecycle 28 | 29 | - (void)viewDidLoad 30 | { 31 | [super viewDidLoad]; 32 | // Do any additional setup after loading the view, typically from a nib. 33 | } 34 | 35 | - (void)viewDidUnload 36 | { 37 | [super viewDidUnload]; 38 | // Release any retained subviews of the main view. 39 | // e.g. self.myOutlet = nil; 40 | } 41 | 42 | - (void)viewWillAppear:(BOOL)animated 43 | { 44 | [super viewWillAppear:animated]; 45 | } 46 | 47 | - (void)viewDidAppear:(BOOL)animated 48 | { 49 | [super viewDidAppear:animated]; 50 | } 51 | 52 | - (void)viewWillDisappear:(BOOL)animated 53 | { 54 | [super viewWillDisappear:animated]; 55 | } 56 | 57 | - (void)viewDidDisappear:(BOOL)animated 58 | { 59 | [super viewDidDisappear:animated]; 60 | } 61 | 62 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 63 | { 64 | // Return YES for supported orientations 65 | if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 66 | return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 67 | } else { 68 | return YES; 69 | } 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample/EXAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // EXAppDelegate.m 3 | // THWebViewControllerExample 4 | // 5 | // Created by 松野 トクヒロ on 12/01/07. 6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "EXAppDelegate.h" 10 | 11 | @implementation EXAppDelegate 12 | 13 | @synthesize window = _window; 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | // Override point for customization after application launch. 18 | return YES; 19 | } 20 | 21 | - (void)applicationWillResignActive:(UIApplication *)application 22 | { 23 | /* 24 | Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | */ 27 | } 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application 30 | { 31 | /* 32 | Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 33 | If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 34 | */ 35 | } 36 | 37 | - (void)applicationWillEnterForeground:(UIApplication *)application 38 | { 39 | /* 40 | Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 41 | */ 42 | } 43 | 44 | - (void)applicationDidBecomeActive:(UIApplication *)application 45 | { 46 | /* 47 | Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 48 | */ 49 | } 50 | 51 | - (void)applicationWillTerminate:(UIApplication *)application 52 | { 53 | /* 54 | Called when the application is about to terminate. 55 | Save data if appropriate. 56 | See also applicationDidEnterBackground:. 57 | */ 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample.xcodeproj/xcuserdata/tokuhirom.xcuserdatad/xcschemes/THWebViewControllerExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 49 | 50 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample/en.lproj/MainStoryboard_iPhone.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample/en.lproj/MainStoryboard_iPad.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /THWebViewController/THWebController.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2011 Roger Chapman 3 | // Copyright 2011 Benedikt Meurer 4 | // 5 | // Forked from Three20 July 29, 2011 - Copyright 2009-2011 Facebook 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | // 19 | 20 | #import 21 | #import 22 | 23 | //#import "NIPreprocessorMacros.h" /* for NI_WEAK */ 24 | 25 | /** 26 | * A simple web view controller implementation with a toolbar. 27 | * 28 | *

Subclassing

29 | * 30 | * This view controller implements UIWebViewDelegate. If you want to 31 | * implement methods of this delegate then you should take care to call the super implementation 32 | * if necessary. The following UIViewWebDelegate methods have implementations in this class: 33 | * 34 | * @code 35 | * - webView:shouldStartLoadWithRequest:navigationType: 36 | * - webViewDidStartLoad: 37 | * - webViewDidFinishLoad: 38 | * - webView:didFailLoadWithError: 39 | * @endcode 40 | * 41 | * This view controller also implements UIActionSheetDelegate. If you want to implement methods of 42 | * this delegate then you should take care to call the super implementation if necessary. The 43 | * following UIActionSheetDelegate methods have implementations in this class: 44 | * 45 | * @code 46 | * - actionSheet:clickedButtonAtIndex: 47 | * - actionSheet:didDismissWithButtonIndex: 48 | * @endcode 49 | * 50 | * In addition to the above methods of the UIActionSheetDelegate, this view controller also provides 51 | * the following method, which is invoked prior to presenting the internal action sheet to the user 52 | * and allows subclasses to customize the action sheet or even reject to display it (and provide their 53 | * own handling instead): 54 | * 55 | * @code 56 | * - shouldPresentActionSheet: 57 | * @endcode 58 | * 59 | * 60 | *

Recommended Configurations

61 | * 62 | *

Default

63 | * 64 | * The default settings will create a toolbar with the default tint color, which is normally 65 | * light blue on the iPhone and gray on the iPad. 66 | * 67 | * 68 | *

Colored Toolbar

69 | * 70 | * The following settings will change the toolbar tint color (in this case black) 71 | * 72 | * @code 73 | * [webController setToolbarTintColor:[UIColor blackColor]]; 74 | * @endcode 75 | * 76 | * @ingroup NimbusWebController 77 | */ 78 | #if defined(__has_feature) && __has_feature(objc_arc_weak) 79 | #define NI_WEAK weak 80 | #define NI_STRONG strong 81 | #elif defined(__has_feature) && __has_feature(objc_arc) 82 | #define NI_WEAK unsafe_unretained 83 | #define NI_STRONG retain 84 | #else 85 | #define NI_WEAK assign 86 | #define NI_STRONG retain 87 | #endif 88 | 89 | 90 | 91 | 92 | @interface THWebController : UIViewController 93 | 94 | // Designated initializer. 95 | - (id)initWithRequest:(NSURLRequest *)request; 96 | - (id)initWithURL:(NSURL *)URL; 97 | 98 | - (NSURL *)URL; 99 | 100 | - (void)openURL:(NSURL*)URL; 101 | - (void)openRequest:(NSURLRequest*)request; 102 | - (void)openHTMLString:(NSString*)htmlString baseURL:(NSURL*)baseUrl; 103 | 104 | @property (nonatomic, readwrite, assign, getter = isToolbarHidden) BOOL toolbarHidden; 105 | @property (nonatomic, readwrite, NI_WEAK) UIColor* toolbarTintColor; 106 | 107 | @property (nonatomic, readonly, NI_STRONG) UIWebView* webView; 108 | 109 | // Subclassing 110 | - (BOOL)shouldPresentActionSheet:(UIActionSheet *)actionSheet; 111 | @property (nonatomic, readwrite, NI_STRONG) NSURL* actionSheetURL; 112 | 113 | @end 114 | 115 | /** @name Creating a Web Controller */ 116 | 117 | /** 118 | * Initializes a newly allocated web controller with a given request. 119 | * 120 | * Once the controller is presented it will begin loading the given request. 121 | * 122 | * This is the designated initializer. 123 | * 124 | * @fn NIWebController::initWithRequest: 125 | */ 126 | 127 | /** 128 | * Initializes a newly allocated web controller with a given URL to request. 129 | * 130 | * Once the controller is presented it will begin loading the given URL. 131 | * 132 | * @fn NIWebController::initWithURL: 133 | */ 134 | 135 | /** @name Accessing the Request Attributes */ 136 | 137 | /** 138 | * The current web view URL. 139 | * 140 | * If the web view is currently loading a URL then the loading URL is returned. 141 | * Otherwise this will be the last URL that was loaded. 142 | * 143 | * @fn NIWebController::URL: 144 | */ 145 | 146 | /** @name Loading a Request */ 147 | 148 | /** 149 | * Loads a request with the given URL in the web view. 150 | * 151 | * @fn NIWebController::openURL: 152 | */ 153 | 154 | /** 155 | * Load the given request using UIWebView's loadRequest:. 156 | * 157 | * @param request A URL request identifying the location of the content to load. 158 | * 159 | * @fn NIWebController::openRequest: 160 | */ 161 | 162 | /** 163 | * Load the given request using UIWebView's loadHTMLString:baseURL:. 164 | * 165 | * @param htmlString The content for the main page. 166 | * @param baseUrl The base URL for the content. 167 | * 168 | * @fn NIWebController::openHTMLString:baseURL: 169 | */ 170 | 171 | /** @name Accessing the Toolbar */ 172 | 173 | /** 174 | * The visibility of the toolbar. 175 | * 176 | * If the toolbar is hidden then the web view will take up the controller's entire view. 177 | * 178 | * @fn NIWebController::toolbarHidden 179 | */ 180 | 181 | /** 182 | * The tint color of the toolbar. 183 | * 184 | * @fn NIWebController::toolbarTintColor 185 | */ 186 | 187 | /** @name Accessing the Web View */ 188 | 189 | /** 190 | * The internal web view. 191 | * 192 | * @fn NIWebController::webView 193 | */ 194 | 195 | /** @name Subclassing the Web Controller */ 196 | 197 | /** 198 | * This message is called in response to the user clicking the action toolbar button. 199 | * 200 | * You can provide your own implementation in your subclass and customize the actionSheet 201 | * that is shown to the user or even cancel the presentation of the @c actionSheet by 202 | * returning NO from your implementation. 203 | * 204 | * @param actionSheet The UIActionSheet that will be presented to the user. 205 | * @return YES to present the actionSheet, NO if you want to perform a custom action. 206 | * @fn NIWebController::shouldPresentActionSheet: 207 | */ 208 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /THWebViewControllerExample/THWebViewControllerExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A811803C14B808C000FEADDD /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A811803B14B808C000FEADDD /* UIKit.framework */; }; 11 | A811803E14B808C000FEADDD /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A811803D14B808C000FEADDD /* Foundation.framework */; }; 12 | A811804014B808C000FEADDD /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A811803F14B808C000FEADDD /* CoreGraphics.framework */; }; 13 | A811804614B808C000FEADDD /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A811804414B808C000FEADDD /* InfoPlist.strings */; }; 14 | A811804814B808C000FEADDD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A811804714B808C000FEADDD /* main.m */; }; 15 | A811804C14B808C000FEADDD /* EXAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A811804B14B808C000FEADDD /* EXAppDelegate.m */; }; 16 | A811804F14B808C000FEADDD /* MainStoryboard_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A811804D14B808C000FEADDD /* MainStoryboard_iPhone.storyboard */; }; 17 | A811805214B808C000FEADDD /* MainStoryboard_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A811805014B808C000FEADDD /* MainStoryboard_iPad.storyboard */; }; 18 | A811805514B808C000FEADDD /* EXViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A811805414B808C000FEADDD /* EXViewController.m */; }; 19 | A811806014B808F500FEADDD /* THWebController.bundle in Resources */ = {isa = PBXBuildFile; fileRef = A811805D14B808F500FEADDD /* THWebController.bundle */; }; 20 | A811806114B808F500FEADDD /* THWebController.m in Sources */ = {isa = PBXBuildFile; fileRef = A811805F14B808F500FEADDD /* THWebController.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | A811803714B808C000FEADDD /* THWebViewControllerExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = THWebViewControllerExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | A811803B14B808C000FEADDD /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 26 | A811803D14B808C000FEADDD /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 27 | A811803F14B808C000FEADDD /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 28 | A811804314B808C000FEADDD /* THWebViewControllerExample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "THWebViewControllerExample-Info.plist"; sourceTree = ""; }; 29 | A811804514B808C000FEADDD /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 30 | A811804714B808C000FEADDD /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 31 | A811804914B808C000FEADDD /* THWebViewControllerExample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "THWebViewControllerExample-Prefix.pch"; sourceTree = ""; }; 32 | A811804A14B808C000FEADDD /* EXAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EXAppDelegate.h; sourceTree = ""; }; 33 | A811804B14B808C000FEADDD /* EXAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EXAppDelegate.m; sourceTree = ""; }; 34 | A811804E14B808C000FEADDD /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPhone.storyboard; sourceTree = ""; }; 35 | A811805114B808C000FEADDD /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPad.storyboard; sourceTree = ""; }; 36 | A811805314B808C000FEADDD /* EXViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EXViewController.h; sourceTree = ""; }; 37 | A811805414B808C000FEADDD /* EXViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EXViewController.m; sourceTree = ""; }; 38 | A811805D14B808F500FEADDD /* THWebController.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = THWebController.bundle; path = ../../THWebViewController/THWebController.bundle; sourceTree = ""; }; 39 | A811805E14B808F500FEADDD /* THWebController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = THWebController.h; path = ../../THWebViewController/THWebController.h; sourceTree = ""; }; 40 | A811805F14B808F500FEADDD /* THWebController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = THWebController.m; path = ../../THWebViewController/THWebController.m; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | A811803414B808BF00FEADDD /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | A811803C14B808C000FEADDD /* UIKit.framework in Frameworks */, 49 | A811803E14B808C000FEADDD /* Foundation.framework in Frameworks */, 50 | A811804014B808C000FEADDD /* CoreGraphics.framework in Frameworks */, 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXFrameworksBuildPhase section */ 55 | 56 | /* Begin PBXGroup section */ 57 | A811802C14B808BF00FEADDD = { 58 | isa = PBXGroup; 59 | children = ( 60 | A811804114B808C000FEADDD /* THWebViewControllerExample */, 61 | A811803A14B808C000FEADDD /* Frameworks */, 62 | A811803814B808C000FEADDD /* Products */, 63 | ); 64 | sourceTree = ""; 65 | }; 66 | A811803814B808C000FEADDD /* Products */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | A811803714B808C000FEADDD /* THWebViewControllerExample.app */, 70 | ); 71 | name = Products; 72 | sourceTree = ""; 73 | }; 74 | A811803A14B808C000FEADDD /* Frameworks */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | A811803B14B808C000FEADDD /* UIKit.framework */, 78 | A811803D14B808C000FEADDD /* Foundation.framework */, 79 | A811803F14B808C000FEADDD /* CoreGraphics.framework */, 80 | ); 81 | name = Frameworks; 82 | sourceTree = ""; 83 | }; 84 | A811804114B808C000FEADDD /* THWebViewControllerExample */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | A811805B14B808D100FEADDD /* vendor */, 88 | A811804A14B808C000FEADDD /* EXAppDelegate.h */, 89 | A811804B14B808C000FEADDD /* EXAppDelegate.m */, 90 | A811804D14B808C000FEADDD /* MainStoryboard_iPhone.storyboard */, 91 | A811805014B808C000FEADDD /* MainStoryboard_iPad.storyboard */, 92 | A811805314B808C000FEADDD /* EXViewController.h */, 93 | A811805414B808C000FEADDD /* EXViewController.m */, 94 | A811804214B808C000FEADDD /* Supporting Files */, 95 | ); 96 | path = THWebViewControllerExample; 97 | sourceTree = ""; 98 | }; 99 | A811804214B808C000FEADDD /* Supporting Files */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | A811804314B808C000FEADDD /* THWebViewControllerExample-Info.plist */, 103 | A811804414B808C000FEADDD /* InfoPlist.strings */, 104 | A811804714B808C000FEADDD /* main.m */, 105 | A811804914B808C000FEADDD /* THWebViewControllerExample-Prefix.pch */, 106 | ); 107 | name = "Supporting Files"; 108 | sourceTree = ""; 109 | }; 110 | A811805B14B808D100FEADDD /* vendor */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | A811805C14B808D800FEADDD /* THWebViewController */, 114 | ); 115 | name = vendor; 116 | sourceTree = ""; 117 | }; 118 | A811805C14B808D800FEADDD /* THWebViewController */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | A811805D14B808F500FEADDD /* THWebController.bundle */, 122 | A811805E14B808F500FEADDD /* THWebController.h */, 123 | A811805F14B808F500FEADDD /* THWebController.m */, 124 | ); 125 | name = THWebViewController; 126 | sourceTree = ""; 127 | }; 128 | /* End PBXGroup section */ 129 | 130 | /* Begin PBXNativeTarget section */ 131 | A811803614B808BF00FEADDD /* THWebViewControllerExample */ = { 132 | isa = PBXNativeTarget; 133 | buildConfigurationList = A811805814B808C000FEADDD /* Build configuration list for PBXNativeTarget "THWebViewControllerExample" */; 134 | buildPhases = ( 135 | A811803314B808BF00FEADDD /* Sources */, 136 | A811803414B808BF00FEADDD /* Frameworks */, 137 | A811803514B808BF00FEADDD /* Resources */, 138 | ); 139 | buildRules = ( 140 | ); 141 | dependencies = ( 142 | ); 143 | name = THWebViewControllerExample; 144 | productName = THWebViewControllerExample; 145 | productReference = A811803714B808C000FEADDD /* THWebViewControllerExample.app */; 146 | productType = "com.apple.product-type.application"; 147 | }; 148 | /* End PBXNativeTarget section */ 149 | 150 | /* Begin PBXProject section */ 151 | A811802E14B808BF00FEADDD /* Project object */ = { 152 | isa = PBXProject; 153 | attributes = { 154 | LastUpgradeCheck = 0420; 155 | }; 156 | buildConfigurationList = A811803114B808BF00FEADDD /* Build configuration list for PBXProject "THWebViewControllerExample" */; 157 | compatibilityVersion = "Xcode 3.2"; 158 | developmentRegion = English; 159 | hasScannedForEncodings = 0; 160 | knownRegions = ( 161 | en, 162 | ); 163 | mainGroup = A811802C14B808BF00FEADDD; 164 | productRefGroup = A811803814B808C000FEADDD /* Products */; 165 | projectDirPath = ""; 166 | projectRoot = ""; 167 | targets = ( 168 | A811803614B808BF00FEADDD /* THWebViewControllerExample */, 169 | ); 170 | }; 171 | /* End PBXProject section */ 172 | 173 | /* Begin PBXResourcesBuildPhase section */ 174 | A811803514B808BF00FEADDD /* Resources */ = { 175 | isa = PBXResourcesBuildPhase; 176 | buildActionMask = 2147483647; 177 | files = ( 178 | A811804614B808C000FEADDD /* InfoPlist.strings in Resources */, 179 | A811804F14B808C000FEADDD /* MainStoryboard_iPhone.storyboard in Resources */, 180 | A811805214B808C000FEADDD /* MainStoryboard_iPad.storyboard in Resources */, 181 | A811806014B808F500FEADDD /* THWebController.bundle in Resources */, 182 | ); 183 | runOnlyForDeploymentPostprocessing = 0; 184 | }; 185 | /* End PBXResourcesBuildPhase section */ 186 | 187 | /* Begin PBXSourcesBuildPhase section */ 188 | A811803314B808BF00FEADDD /* Sources */ = { 189 | isa = PBXSourcesBuildPhase; 190 | buildActionMask = 2147483647; 191 | files = ( 192 | A811804814B808C000FEADDD /* main.m in Sources */, 193 | A811804C14B808C000FEADDD /* EXAppDelegate.m in Sources */, 194 | A811805514B808C000FEADDD /* EXViewController.m in Sources */, 195 | A811806114B808F500FEADDD /* THWebController.m in Sources */, 196 | ); 197 | runOnlyForDeploymentPostprocessing = 0; 198 | }; 199 | /* End PBXSourcesBuildPhase section */ 200 | 201 | /* Begin PBXVariantGroup section */ 202 | A811804414B808C000FEADDD /* InfoPlist.strings */ = { 203 | isa = PBXVariantGroup; 204 | children = ( 205 | A811804514B808C000FEADDD /* en */, 206 | ); 207 | name = InfoPlist.strings; 208 | sourceTree = ""; 209 | }; 210 | A811804D14B808C000FEADDD /* MainStoryboard_iPhone.storyboard */ = { 211 | isa = PBXVariantGroup; 212 | children = ( 213 | A811804E14B808C000FEADDD /* en */, 214 | ); 215 | name = MainStoryboard_iPhone.storyboard; 216 | sourceTree = ""; 217 | }; 218 | A811805014B808C000FEADDD /* MainStoryboard_iPad.storyboard */ = { 219 | isa = PBXVariantGroup; 220 | children = ( 221 | A811805114B808C000FEADDD /* en */, 222 | ); 223 | name = MainStoryboard_iPad.storyboard; 224 | sourceTree = ""; 225 | }; 226 | /* End PBXVariantGroup section */ 227 | 228 | /* Begin XCBuildConfiguration section */ 229 | A811805614B808C000FEADDD /* Debug */ = { 230 | isa = XCBuildConfiguration; 231 | buildSettings = { 232 | ALWAYS_SEARCH_USER_PATHS = NO; 233 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 234 | CLANG_ENABLE_OBJC_ARC = YES; 235 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 236 | COPY_PHASE_STRIP = NO; 237 | GCC_C_LANGUAGE_STANDARD = gnu99; 238 | GCC_DYNAMIC_NO_PIC = NO; 239 | GCC_OPTIMIZATION_LEVEL = 0; 240 | GCC_PREPROCESSOR_DEFINITIONS = ( 241 | "DEBUG=1", 242 | "$(inherited)", 243 | ); 244 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 245 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 246 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 247 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 248 | GCC_WARN_UNUSED_VARIABLE = YES; 249 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 250 | SDKROOT = iphoneos; 251 | TARGETED_DEVICE_FAMILY = "1,2"; 252 | }; 253 | name = Debug; 254 | }; 255 | A811805714B808C000FEADDD /* Release */ = { 256 | isa = XCBuildConfiguration; 257 | buildSettings = { 258 | ALWAYS_SEARCH_USER_PATHS = NO; 259 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 260 | CLANG_ENABLE_OBJC_ARC = YES; 261 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 262 | COPY_PHASE_STRIP = YES; 263 | GCC_C_LANGUAGE_STANDARD = gnu99; 264 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 265 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 266 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 267 | GCC_WARN_UNUSED_VARIABLE = YES; 268 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 269 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 270 | SDKROOT = iphoneos; 271 | TARGETED_DEVICE_FAMILY = "1,2"; 272 | VALIDATE_PRODUCT = YES; 273 | }; 274 | name = Release; 275 | }; 276 | A811805914B808C000FEADDD /* Debug */ = { 277 | isa = XCBuildConfiguration; 278 | buildSettings = { 279 | CLANG_ENABLE_OBJC_ARC = YES; 280 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 281 | GCC_PREFIX_HEADER = "THWebViewControllerExample/THWebViewControllerExample-Prefix.pch"; 282 | INFOPLIST_FILE = "THWebViewControllerExample/THWebViewControllerExample-Info.plist"; 283 | PRODUCT_NAME = "$(TARGET_NAME)"; 284 | WRAPPER_EXTENSION = app; 285 | }; 286 | name = Debug; 287 | }; 288 | A811805A14B808C000FEADDD /* Release */ = { 289 | isa = XCBuildConfiguration; 290 | buildSettings = { 291 | CLANG_ENABLE_OBJC_ARC = YES; 292 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 293 | GCC_PREFIX_HEADER = "THWebViewControllerExample/THWebViewControllerExample-Prefix.pch"; 294 | INFOPLIST_FILE = "THWebViewControllerExample/THWebViewControllerExample-Info.plist"; 295 | PRODUCT_NAME = "$(TARGET_NAME)"; 296 | WRAPPER_EXTENSION = app; 297 | }; 298 | name = Release; 299 | }; 300 | /* End XCBuildConfiguration section */ 301 | 302 | /* Begin XCConfigurationList section */ 303 | A811803114B808BF00FEADDD /* Build configuration list for PBXProject "THWebViewControllerExample" */ = { 304 | isa = XCConfigurationList; 305 | buildConfigurations = ( 306 | A811805614B808C000FEADDD /* Debug */, 307 | A811805714B808C000FEADDD /* Release */, 308 | ); 309 | defaultConfigurationIsVisible = 0; 310 | defaultConfigurationName = Release; 311 | }; 312 | A811805814B808C000FEADDD /* Build configuration list for PBXNativeTarget "THWebViewControllerExample" */ = { 313 | isa = XCConfigurationList; 314 | buildConfigurations = ( 315 | A811805914B808C000FEADDD /* Debug */, 316 | A811805A14B808C000FEADDD /* Release */, 317 | ); 318 | defaultConfigurationIsVisible = 0; 319 | defaultConfigurationName = Release; 320 | }; 321 | /* End XCConfigurationList section */ 322 | }; 323 | rootObject = A811802E14B808BF00FEADDD /* Project object */; 324 | } 325 | -------------------------------------------------------------------------------- /THWebViewController/THWebController.m: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2011 Roger Chapman 3 | // Copyright 2011 Benedikt Meurer 4 | // 5 | // Forked from Three20 July 29, 2011 - Copyright 2009-2011 Facebook 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | // 19 | 20 | #import "THWebController.h" 21 | 22 | //#import "NimbusCore.h" 23 | 24 | #if !defined(__has_feature) || !__has_feature(objc_arc) 25 | #error "Nimbus requires ARC support." 26 | #endif 27 | 28 | static CGRect NIRectContract(CGRect rect, CGFloat dx, CGFloat dy) { 29 | return CGRectMake(rect.origin.x, rect.origin.y, rect.size.width - dx, rect.size.height - dy); 30 | } 31 | 32 | static BOOL NIIsPad(void) { 33 | #ifdef UI_USER_INTERFACE_IDIOM 34 | static NSInteger isPad = -1; 35 | if (isPad < 0) { 36 | isPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad); 37 | } 38 | return isPad > 0; 39 | #else 40 | return NO; 41 | #endif 42 | } 43 | 44 | static CGFloat NIToolbarHeightForOrientation(UIInterfaceOrientation orientation) { 45 | return (NIIsPad() 46 | ? 44 47 | : (UIInterfaceOrientationIsPortrait(orientation) 48 | ? 44 49 | : 33));; 50 | } 51 | 52 | static UIInterfaceOrientation NIInterfaceOrientation(void) { 53 | UIInterfaceOrientation orient = [UIApplication sharedApplication].statusBarOrientation; 54 | 55 | // This code used to use the navigator to find the currently visible view controller and 56 | // fall back to checking its orientation if we didn't know the status bar's orientation. 57 | // It's unclear when this was actually necessary, though, so this assertion is here to try 58 | // to find that case. If this assertion fails then the repro case needs to be analyzed and 59 | // this method made more robust to handle that case. 60 | // XXX NSParameterAssert(UIDeviceOrientationUnknown != orient); 61 | 62 | return orient; 63 | } 64 | 65 | static NSString* NIPathForBundleResource(NSBundle* bundle, NSString* relativePath) { 66 | NSString* resourcePath = [(nil == bundle ? [NSBundle mainBundle] : bundle) resourcePath]; 67 | return [resourcePath stringByAppendingPathComponent:relativePath]; 68 | } 69 | 70 | 71 | @interface THWebController() 72 | @property (nonatomic, readwrite, NI_STRONG) UIWebView* webView; 73 | @property (nonatomic, readwrite, NI_STRONG) UIToolbar* toolbar; 74 | @property (nonatomic, readwrite, NI_STRONG) UIActionSheet* actionSheet; 75 | 76 | @property (nonatomic, readwrite, NI_STRONG) UIBarButtonItem* backButton; 77 | @property (nonatomic, readwrite, NI_STRONG) UIBarButtonItem* forwardButton; 78 | @property (nonatomic, readwrite, NI_STRONG) UIBarButtonItem* refreshButton; 79 | @property (nonatomic, readwrite, NI_STRONG) UIBarButtonItem* stopButton; 80 | @property (nonatomic, readwrite, NI_STRONG) UIBarButtonItem* actionButton; 81 | @property (nonatomic, readwrite, NI_STRONG) UIBarButtonItem* activityItem; 82 | 83 | @property (nonatomic, readwrite, NI_STRONG) NSURL* loadingURL; 84 | 85 | @property (nonatomic, readwrite, NI_STRONG) NSURLRequest* loadRequest; 86 | @end 87 | 88 | /////////////////////////////////////////////////////////////////////////////////////////////////// 89 | /////////////////////////////////////////////////////////////////////////////////////////////////// 90 | /////////////////////////////////////////////////////////////////////////////////////////////////// 91 | @implementation THWebController 92 | 93 | @synthesize webView = _webView; 94 | @synthesize toolbar = _toolbar; 95 | @synthesize actionSheet = _actionSheet; 96 | @synthesize backButton = _backButton; 97 | @synthesize forwardButton = _forwardButton; 98 | @synthesize refreshButton = _refreshButton; 99 | @synthesize stopButton = _stopButton; 100 | @synthesize actionButton = _actionButton; 101 | @synthesize activityItem = _activityItem; 102 | @synthesize actionSheetURL = _actionSheetURL; 103 | @synthesize loadingURL = _loadingURL; 104 | @synthesize loadRequest = _loadRequest; 105 | @synthesize toolbarHidden = _toolbarHidden; 106 | @synthesize toolbarTintColor = _toolbarTintColor; 107 | 108 | 109 | /////////////////////////////////////////////////////////////////////////////////////////////////// 110 | - (void)dealloc { 111 | _actionSheet.delegate = nil; 112 | _webView.delegate = nil; 113 | } 114 | 115 | 116 | /////////////////////////////////////////////////////////////////////////////////////////////////// 117 | - (id)initWithRequest:(NSURLRequest *)request { 118 | if ((self = [super initWithNibName:nil bundle:nil])) { 119 | self.hidesBottomBarWhenPushed = YES; 120 | [self openRequest:request]; 121 | } 122 | return self; 123 | } 124 | 125 | 126 | /////////////////////////////////////////////////////////////////////////////////////////////////// 127 | - (id)initWithURL:(NSURL *)URL { 128 | return [self initWithRequest:[NSURLRequest requestWithURL:URL]]; 129 | } 130 | 131 | 132 | /////////////////////////////////////////////////////////////////////////////////////////////////// 133 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 134 | return [self initWithRequest:nil]; 135 | } 136 | 137 | 138 | /////////////////////////////////////////////////////////////////////////////////////////////////// 139 | /////////////////////////////////////////////////////////////////////////////////////////////////// 140 | #pragma mark - Private 141 | 142 | 143 | /////////////////////////////////////////////////////////////////////////////////////////////////// 144 | - (void)didTapBackButton { 145 | [self.webView goBack]; 146 | } 147 | 148 | 149 | /////////////////////////////////////////////////////////////////////////////////////////////////// 150 | - (void)didTapForwardButton { 151 | [self.webView goForward]; 152 | } 153 | 154 | 155 | /////////////////////////////////////////////////////////////////////////////////////////////////// 156 | - (void)didTapRefreshButton { 157 | [self.webView reload]; 158 | } 159 | 160 | 161 | /////////////////////////////////////////////////////////////////////////////////////////////////// 162 | - (void)didTapStopButton { 163 | [self.webView stopLoading]; 164 | } 165 | 166 | 167 | /////////////////////////////////////////////////////////////////////////////////////////////////// 168 | - (void)didTapShareButton { 169 | // Dismiss the action menu if the user taps the action button again on the iPad. 170 | if ([self.actionSheet isVisible]) { 171 | // It shouldn't be possible to tap the share action button again on anything but the iPad. 172 | NSParameterAssert(NIIsPad()); 173 | 174 | [self.actionSheet dismissWithClickedButtonIndex:[self.actionSheet cancelButtonIndex] animated:YES]; 175 | 176 | // We remove the action sheet here just in case the delegate isn't properly implemented. 177 | self.actionSheet.delegate = nil; 178 | self.actionSheet = nil; 179 | self.actionSheetURL = nil; 180 | 181 | // Don't show the menu again. 182 | return; 183 | } 184 | 185 | // Remember the URL at this point 186 | self.actionSheetURL = [self.URL copy]; 187 | 188 | if (nil == self.actionSheet) { 189 | self.actionSheet = 190 | [[UIActionSheet alloc] initWithTitle:[self.actionSheetURL absoluteString] 191 | delegate:self 192 | cancelButtonTitle:nil 193 | destructiveButtonTitle:nil 194 | otherButtonTitles:nil]; 195 | 196 | // Let -shouldPresentActionSheet: setup the action sheet 197 | if (![self shouldPresentActionSheet:self.actionSheet]) { 198 | // A subclass decided to handle the action in another way 199 | self.actionSheet = nil; 200 | self.actionSheetURL = nil; 201 | return; 202 | } 203 | // Add "Cancel" button except for iPads 204 | if (!NIIsPad()) { 205 | [self.actionSheet setCancelButtonIndex:[self.actionSheet addButtonWithTitle:NSLocalizedString(@"Cancel", @"")]]; 206 | } 207 | } 208 | 209 | if (NIIsPad()) { 210 | [self.actionSheet showFromBarButtonItem:self.actionButton animated:YES]; 211 | } else { 212 | [self.actionSheet showInView:self.view]; 213 | } 214 | } 215 | 216 | 217 | /////////////////////////////////////////////////////////////////////////////////////////////////// 218 | - (void)updateToolbarWithOrientation:(UIInterfaceOrientation)interfaceOrientation { 219 | if (!self.toolbarHidden) { 220 | CGRect toolbarFrame = self.toolbar.frame; 221 | toolbarFrame.size.height = NIToolbarHeightForOrientation(interfaceOrientation); 222 | toolbarFrame.origin.y = self.view.bounds.size.height - toolbarFrame.size.height; 223 | self.toolbar.frame = toolbarFrame; 224 | 225 | CGRect webViewFrame = self.webView.frame; 226 | webViewFrame.size.height = self.view.bounds.size.height - toolbarFrame.size.height; 227 | self.webView.frame = webViewFrame; 228 | 229 | } else { 230 | self.webView.frame = self.view.bounds; 231 | } 232 | } 233 | 234 | 235 | /////////////////////////////////////////////////////////////////////////////////////////////////// 236 | /////////////////////////////////////////////////////////////////////////////////////////////////// 237 | #pragma mark - UIViewController 238 | 239 | 240 | /////////////////////////////////////////////////////////////////////////////////////////////////// 241 | - (void)updateWebViewFrame { 242 | if (self.toolbarHidden) { 243 | self.webView.frame = self.view.bounds; 244 | 245 | } else { 246 | self.webView.frame = NIRectContract(self.view.bounds, 0, self.toolbar.frame.size.height); 247 | } 248 | } 249 | 250 | 251 | /////////////////////////////////////////////////////////////////////////////////////////////////// 252 | - (void)loadView { 253 | [super loadView]; 254 | 255 | CGRect bounds = self.view.bounds; 256 | 257 | CGFloat toolbarHeight = NIToolbarHeightForOrientation(NIInterfaceOrientation()); 258 | CGRect toolbarFrame = CGRectMake(0, bounds.size.height - toolbarHeight, 259 | bounds.size.width, toolbarHeight); 260 | 261 | self.toolbar = [[UIToolbar alloc] initWithFrame:toolbarFrame]; 262 | self.toolbar.autoresizingMask = (UIViewAutoresizingFlexibleTopMargin 263 | | UIViewAutoresizingFlexibleWidth); 264 | self.toolbar.tintColor = self.toolbarTintColor; 265 | self.toolbar.hidden = self.toolbarHidden; 266 | 267 | UIActivityIndicatorView* spinner = 268 | [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: 269 | UIActivityIndicatorViewStyleWhite]; 270 | [spinner startAnimating]; 271 | self.activityItem = [[UIBarButtonItem alloc] initWithCustomView:spinner]; 272 | 273 | UIImage* backIcon = [UIImage imageWithContentsOfFile: 274 | NIPathForBundleResource(nil, @"THWebController.bundle/gfx/backIcon.png")]; 275 | // We weren't able to find the forward or back icons in your application's resources. 276 | // Ensure that you've dragged the NimbusWebController.bundle from src/webcontroller/resources 277 | //into your application with the "Create Folder References" option selected. You can verify that 278 | // you've done this correctly by expanding the NimbusPhotos.bundle file in your project 279 | // and verifying that the 'gfx' directory is blue. Also verify that the bundle is being 280 | // copied in the Copy Bundle Resources phase. 281 | NSParameterAssert(nil != backIcon); 282 | 283 | self.backButton = 284 | [[UIBarButtonItem alloc] initWithImage:backIcon 285 | style:UIBarButtonItemStylePlain 286 | target:self 287 | action:@selector(didTapBackButton)]; 288 | self.backButton.tag = 2; 289 | self.backButton.enabled = NO; 290 | 291 | UIImage* forwardIcon = [UIImage imageWithContentsOfFile: 292 | NIPathForBundleResource(nil, @"THWebController.bundle/gfx/forwardIcon.png")]; 293 | // We weren't able to find the forward or back icons in your application's resources. 294 | // Ensure that you've dragged the NimbusWebController.bundle from src/webcontroller/resources 295 | // into your application with the "Create Folder References" option selected. You can verify that 296 | // you've done this correctly by expanding the NimbusPhotos.bundle file in your project 297 | // and verifying that the 'gfx' directory is blue. Also verify that the bundle is being 298 | // copied in the Copy Bundle Resources phase. 299 | NSParameterAssert(nil != forwardIcon); 300 | 301 | self.forwardButton = 302 | [[UIBarButtonItem alloc] initWithImage:forwardIcon 303 | style:UIBarButtonItemStylePlain 304 | target:self 305 | action:@selector(didTapForwardButton)]; 306 | self.forwardButton.tag = 1; 307 | self.forwardButton.enabled = NO; 308 | self.refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: 309 | UIBarButtonSystemItemRefresh target:self action:@selector(didTapRefreshButton)]; 310 | self.refreshButton.tag = 3; 311 | self.stopButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: 312 | UIBarButtonSystemItemStop target:self action:@selector(didTapStopButton)]; 313 | self.stopButton.tag = 3; 314 | self.actionButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: 315 | UIBarButtonSystemItemAction target:self action:@selector(didTapShareButton)]; 316 | 317 | UIBarItem* flexibleSpace = 318 | [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace 319 | target: nil 320 | action: nil]; 321 | 322 | self.toolbar.items = [NSArray arrayWithObjects: 323 | self.backButton, 324 | flexibleSpace, 325 | self.forwardButton, 326 | flexibleSpace, 327 | self.refreshButton, 328 | flexibleSpace, 329 | self.actionButton, 330 | nil]; 331 | [self.view addSubview:self.toolbar]; 332 | 333 | self.webView = [[UIWebView alloc] initWithFrame:CGRectZero]; 334 | [self updateWebViewFrame]; 335 | self.webView.delegate = self; 336 | self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth 337 | | UIViewAutoresizingFlexibleHeight); 338 | self.webView.scalesPageToFit = YES; 339 | 340 | if ([UIColor respondsToSelector:@selector(underPageBackgroundColor)]) { 341 | self.webView.backgroundColor = [UIColor underPageBackgroundColor]; 342 | } 343 | 344 | [self.view addSubview:self.webView]; 345 | 346 | if (nil != self.loadRequest) { 347 | [self.webView loadRequest:self.loadRequest]; 348 | } 349 | } 350 | 351 | 352 | /////////////////////////////////////////////////////////////////////////////////////////////////// 353 | - (void)viewDidUnload { 354 | [super viewDidUnload]; 355 | 356 | self.actionSheet.delegate = nil; 357 | self.webView.delegate = nil; 358 | 359 | self.actionSheet = nil; 360 | self.webView = nil; 361 | self.toolbar = nil; 362 | self.backButton = nil; 363 | self.forwardButton = nil; 364 | self.refreshButton = nil; 365 | self.stopButton = nil; 366 | self.actionButton = nil; 367 | self.activityItem = nil; 368 | } 369 | 370 | 371 | /////////////////////////////////////////////////////////////////////////////////////////////////// 372 | - (void)viewWillAppear:(BOOL)animated { 373 | [super viewWillAppear:animated]; 374 | 375 | [self updateToolbarWithOrientation:self.interfaceOrientation]; 376 | } 377 | 378 | 379 | /////////////////////////////////////////////////////////////////////////////////////////////////// 380 | - (void)viewWillDisappear:(BOOL)animated { 381 | // If the browser launched the media player, it steals the key window and never gives it 382 | // back, so this is a way to try and fix that. 383 | [self.view.window makeKeyWindow]; 384 | 385 | [super viewWillDisappear:animated]; 386 | } 387 | 388 | 389 | /////////////////////////////////////////////////////////////////////////////////////////////////// 390 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 391 | if (NIIsPad()) { 392 | return YES; 393 | } else { 394 | switch (interfaceOrientation) { 395 | case UIInterfaceOrientationPortrait: 396 | case UIInterfaceOrientationLandscapeLeft: 397 | case UIInterfaceOrientationLandscapeRight: 398 | return YES; 399 | default: 400 | return NO; 401 | } 402 | } 403 | } 404 | 405 | 406 | /////////////////////////////////////////////////////////////////////////////////////////////////// 407 | - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 408 | duration:(NSTimeInterval)duration { 409 | [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; 410 | [self updateToolbarWithOrientation:toInterfaceOrientation]; 411 | } 412 | 413 | 414 | /////////////////////////////////////////////////////////////////////////////////////////////////// 415 | /////////////////////////////////////////////////////////////////////////////////////////////////// 416 | #pragma mark - UIWebViewDelegate 417 | 418 | 419 | /////////////////////////////////////////////////////////////////////////////////////////////////// 420 | - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType { 421 | self.loadingURL = [request.mainDocumentURL copy]; 422 | self.backButton.enabled = [self.webView canGoBack]; 423 | self.forwardButton.enabled = [self.webView canGoForward]; 424 | return YES; 425 | } 426 | 427 | 428 | /////////////////////////////////////////////////////////////////////////////////////////////////// 429 | - (void)webViewDidStartLoad:(UIWebView*)webView { 430 | self.title = NSLocalizedString(@"Loading...", @""); 431 | if (!self.navigationItem.rightBarButtonItem) { 432 | [self.navigationItem setRightBarButtonItem:self.activityItem animated:YES]; 433 | } 434 | 435 | NSInteger buttonIndex = 0; 436 | for (UIBarButtonItem* button in self.toolbar.items) { 437 | if (button.tag == 3) { 438 | NSMutableArray* newItems = [NSMutableArray arrayWithArray:self.toolbar.items]; 439 | [newItems replaceObjectAtIndex:buttonIndex withObject:self.stopButton]; 440 | self.toolbar.items = newItems; 441 | break; 442 | } 443 | ++buttonIndex; 444 | } 445 | self.backButton.enabled = [self.webView canGoBack]; 446 | self.forwardButton.enabled = [self.webView canGoForward]; 447 | } 448 | 449 | 450 | /////////////////////////////////////////////////////////////////////////////////////////////////// 451 | - (void)webViewDidFinishLoad:(UIWebView*)webView { 452 | self.loadingURL = nil; 453 | self.title = [self.webView stringByEvaluatingJavaScriptFromString:@"document.title"]; 454 | if (self.navigationItem.rightBarButtonItem == self.activityItem) { 455 | [self.navigationItem setRightBarButtonItem:nil animated:YES]; 456 | } 457 | 458 | NSInteger buttonIndex = 0; 459 | for (UIBarButtonItem* button in self.toolbar.items) { 460 | if (button.tag == 3) { 461 | NSMutableArray* newItems = [NSMutableArray arrayWithArray:self.toolbar.items]; 462 | [newItems replaceObjectAtIndex:buttonIndex withObject:self.refreshButton]; 463 | self.toolbar.items = newItems; 464 | break; 465 | } 466 | ++buttonIndex; 467 | } 468 | 469 | self.backButton.enabled = [self.webView canGoBack]; 470 | self.forwardButton.enabled = [self.webView canGoForward]; 471 | } 472 | 473 | 474 | /////////////////////////////////////////////////////////////////////////////////////////////////// 475 | - (void)webView:(UIWebView*)webView didFailLoadWithError:(NSError*)error { 476 | self.loadingURL = nil; 477 | [self webViewDidFinishLoad:webView]; 478 | } 479 | 480 | 481 | /////////////////////////////////////////////////////////////////////////////////////////////////// 482 | /////////////////////////////////////////////////////////////////////////////////////////////////// 483 | #pragma mark - UIActionSheetDelegate 484 | 485 | 486 | /////////////////////////////////////////////////////////////////////////////////////////////////// 487 | - (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 488 | if (actionSheet == self.actionSheet) { 489 | if (buttonIndex == 0) { 490 | [[UIApplication sharedApplication] openURL:self.actionSheetURL]; 491 | } else if (buttonIndex == 1) { 492 | [[UIPasteboard generalPasteboard] setURL:self.actionSheetURL]; 493 | } 494 | } 495 | } 496 | 497 | 498 | /////////////////////////////////////////////////////////////////////////////////////////////////// 499 | - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex { 500 | if (actionSheet == self.actionSheet) { 501 | self.actionSheet.delegate = nil; 502 | self.actionSheet = nil; 503 | self.actionSheetURL = nil; 504 | } 505 | } 506 | 507 | 508 | /////////////////////////////////////////////////////////////////////////////////////////////////// 509 | /////////////////////////////////////////////////////////////////////////////////////////////////// 510 | #pragma mark - Public 511 | 512 | 513 | /////////////////////////////////////////////////////////////////////////////////////////////////// 514 | - (NSURL *)URL { 515 | return self.loadingURL ? self.loadingURL : self.webView.request.mainDocumentURL; 516 | } 517 | 518 | 519 | /////////////////////////////////////////////////////////////////////////////////////////////////// 520 | - (void)openURL:(NSURL*)URL { 521 | NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:URL]; 522 | [self openRequest:request]; 523 | } 524 | 525 | 526 | /////////////////////////////////////////////////////////////////////////////////////////////////// 527 | - (void)openRequest:(NSURLRequest *)request { 528 | self.loadRequest = request; 529 | 530 | if ([self isViewLoaded]) { 531 | if (nil != request) { 532 | [self.webView loadRequest:request]; 533 | 534 | } else { 535 | [self.webView stopLoading]; 536 | } 537 | } 538 | } 539 | 540 | 541 | /////////////////////////////////////////////////////////////////////////////////////////////////// 542 | - (void)openHTMLString:(NSString*)htmlString baseURL:(NSURL*)baseUrl { 543 | NSParameterAssert([self isViewLoaded]); 544 | [_webView loadHTMLString:htmlString baseURL:baseUrl]; 545 | } 546 | 547 | 548 | /////////////////////////////////////////////////////////////////////////////////////////////////// 549 | - (void)setToolbarHidden:(BOOL)hidden { 550 | _toolbarHidden = hidden; 551 | if ([self isViewLoaded]) { 552 | self.toolbar.hidden = hidden; 553 | [self updateWebViewFrame]; 554 | } 555 | } 556 | 557 | 558 | /////////////////////////////////////////////////////////////////////////////////////////////////// 559 | - (void)setToolbarTintColor:(UIColor*)color { 560 | if (color != _toolbarTintColor) { 561 | _toolbarTintColor = color; 562 | } 563 | 564 | if ([self isViewLoaded]) { 565 | self.toolbar.tintColor = color; 566 | } 567 | } 568 | 569 | 570 | /////////////////////////////////////////////////////////////////////////////////////////////////// 571 | - (BOOL)shouldPresentActionSheet:(UIActionSheet *)actionSheet { 572 | if (actionSheet == self.actionSheet) { 573 | [self.actionSheet addButtonWithTitle:NSLocalizedString(@"Open in Safari", @"")]; 574 | [self.actionSheet addButtonWithTitle:NSLocalizedString(@"Copy URL", @"")]; 575 | } 576 | return YES; 577 | } 578 | 579 | 580 | @end 581 | --------------------------------------------------------------------------------