├── 2015-01-31-WKWebViewDemo ├── 2015-01-31-WKWebViewDemo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── tangjr.xcuserdatad │ │ │ ├── UserInterfaceState.xcuserstate │ │ │ └── WorkspaceSettings.xcsettings │ └── xcuserdata │ │ └── tangjr.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── 2015-01-31-WKWebViewDemo.xcscheme │ │ └── xcschememanagement.plist ├── 2015-01-31-WKWebViewDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── BaiduViewController.h │ ├── BaiduViewController.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── JSViewController.h │ ├── JSViewController.m │ ├── OSCViewController.h │ ├── OSCViewController.m │ ├── ViewController.h │ ├── ViewController.m │ ├── add_item_a.png │ └── main.m └── 2015-01-31-WKWebViewDemoTests │ ├── Info.plist │ └── _015_01_31_WKWebViewDemoTests.m └── README.md /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 969AB6651A7D17C20048363E /* JSViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 969AB6641A7D17C20048363E /* JSViewController.m */; }; 11 | 96C9081E1A7C6E710085C453 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 96C9081D1A7C6E710085C453 /* main.m */; }; 12 | 96C908211A7C6E710085C453 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 96C908201A7C6E710085C453 /* AppDelegate.m */; }; 13 | 96C908241A7C6E710085C453 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 96C908231A7C6E710085C453 /* ViewController.m */; }; 14 | 96C908271A7C6E710085C453 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96C908251A7C6E710085C453 /* Main.storyboard */; }; 15 | 96C908291A7C6E710085C453 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96C908281A7C6E710085C453 /* Images.xcassets */; }; 16 | 96C9082C1A7C6E710085C453 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 96C9082A1A7C6E710085C453 /* LaunchScreen.xib */; }; 17 | 96C908381A7C6E710085C453 /* _015_01_31_WKWebViewDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 96C908371A7C6E710085C453 /* _015_01_31_WKWebViewDemoTests.m */; }; 18 | 96C908541A7C76ED0085C453 /* add_item_a.png in Resources */ = {isa = PBXBuildFile; fileRef = 96C908531A7C76ED0085C453 /* add_item_a.png */; }; 19 | 96C908571A7C78E30085C453 /* BaiduViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 96C908561A7C78E30085C453 /* BaiduViewController.m */; }; 20 | 96C9085A1A7C79EA0085C453 /* OSCViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 96C908591A7C79EA0085C453 /* OSCViewController.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | 96C908321A7C6E710085C453 /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 96C908101A7C6E710085C453 /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 96C908171A7C6E710085C453; 29 | remoteInfo = "2015-01-31-WKWebViewDemo"; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 969AB6631A7D17C20048363E /* JSViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSViewController.h; sourceTree = ""; }; 35 | 969AB6641A7D17C20048363E /* JSViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSViewController.m; sourceTree = ""; }; 36 | 96C908181A7C6E710085C453 /* 2015-01-31-WKWebViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "2015-01-31-WKWebViewDemo.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | 96C9081C1A7C6E710085C453 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | 96C9081D1A7C6E710085C453 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 39 | 96C9081F1A7C6E710085C453 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 40 | 96C908201A7C6E710085C453 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 41 | 96C908221A7C6E710085C453 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 42 | 96C908231A7C6E710085C453 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 43 | 96C908261A7C6E710085C453 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 44 | 96C908281A7C6E710085C453 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 45 | 96C9082B1A7C6E710085C453 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 46 | 96C908311A7C6E710085C453 /* 2015-01-31-WKWebViewDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "2015-01-31-WKWebViewDemoTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | 96C908361A7C6E710085C453 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | 96C908371A7C6E710085C453 /* _015_01_31_WKWebViewDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = _015_01_31_WKWebViewDemoTests.m; sourceTree = ""; }; 49 | 96C908531A7C76ED0085C453 /* add_item_a.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = add_item_a.png; sourceTree = ""; }; 50 | 96C908551A7C78E30085C453 /* BaiduViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaiduViewController.h; sourceTree = ""; }; 51 | 96C908561A7C78E30085C453 /* BaiduViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaiduViewController.m; sourceTree = ""; }; 52 | 96C908581A7C79EA0085C453 /* OSCViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSCViewController.h; sourceTree = ""; }; 53 | 96C908591A7C79EA0085C453 /* OSCViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OSCViewController.m; sourceTree = ""; }; 54 | /* End PBXFileReference section */ 55 | 56 | /* Begin PBXFrameworksBuildPhase section */ 57 | 96C908151A7C6E710085C453 /* Frameworks */ = { 58 | isa = PBXFrameworksBuildPhase; 59 | buildActionMask = 2147483647; 60 | files = ( 61 | ); 62 | runOnlyForDeploymentPostprocessing = 0; 63 | }; 64 | 96C9082E1A7C6E710085C453 /* Frameworks */ = { 65 | isa = PBXFrameworksBuildPhase; 66 | buildActionMask = 2147483647; 67 | files = ( 68 | ); 69 | runOnlyForDeploymentPostprocessing = 0; 70 | }; 71 | /* End PBXFrameworksBuildPhase section */ 72 | 73 | /* Begin PBXGroup section */ 74 | 96C9080F1A7C6E710085C453 = { 75 | isa = PBXGroup; 76 | children = ( 77 | 96C9081A1A7C6E710085C453 /* 2015-01-31-WKWebViewDemo */, 78 | 96C908341A7C6E710085C453 /* 2015-01-31-WKWebViewDemoTests */, 79 | 96C908191A7C6E710085C453 /* Products */, 80 | ); 81 | sourceTree = ""; 82 | }; 83 | 96C908191A7C6E710085C453 /* Products */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 96C908181A7C6E710085C453 /* 2015-01-31-WKWebViewDemo.app */, 87 | 96C908311A7C6E710085C453 /* 2015-01-31-WKWebViewDemoTests.xctest */, 88 | ); 89 | name = Products; 90 | sourceTree = ""; 91 | }; 92 | 96C9081A1A7C6E710085C453 /* 2015-01-31-WKWebViewDemo */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 96C9081F1A7C6E710085C453 /* AppDelegate.h */, 96 | 96C908201A7C6E710085C453 /* AppDelegate.m */, 97 | 96C908221A7C6E710085C453 /* ViewController.h */, 98 | 96C908231A7C6E710085C453 /* ViewController.m */, 99 | 96C908551A7C78E30085C453 /* BaiduViewController.h */, 100 | 96C908561A7C78E30085C453 /* BaiduViewController.m */, 101 | 96C908581A7C79EA0085C453 /* OSCViewController.h */, 102 | 96C908591A7C79EA0085C453 /* OSCViewController.m */, 103 | 969AB6631A7D17C20048363E /* JSViewController.h */, 104 | 969AB6641A7D17C20048363E /* JSViewController.m */, 105 | 96C908531A7C76ED0085C453 /* add_item_a.png */, 106 | 96C908251A7C6E710085C453 /* Main.storyboard */, 107 | 96C908281A7C6E710085C453 /* Images.xcassets */, 108 | 96C9082A1A7C6E710085C453 /* LaunchScreen.xib */, 109 | 96C9081B1A7C6E710085C453 /* Supporting Files */, 110 | ); 111 | path = "2015-01-31-WKWebViewDemo"; 112 | sourceTree = ""; 113 | }; 114 | 96C9081B1A7C6E710085C453 /* Supporting Files */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 96C9081C1A7C6E710085C453 /* Info.plist */, 118 | 96C9081D1A7C6E710085C453 /* main.m */, 119 | ); 120 | name = "Supporting Files"; 121 | sourceTree = ""; 122 | }; 123 | 96C908341A7C6E710085C453 /* 2015-01-31-WKWebViewDemoTests */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 96C908371A7C6E710085C453 /* _015_01_31_WKWebViewDemoTests.m */, 127 | 96C908351A7C6E710085C453 /* Supporting Files */, 128 | ); 129 | path = "2015-01-31-WKWebViewDemoTests"; 130 | sourceTree = ""; 131 | }; 132 | 96C908351A7C6E710085C453 /* Supporting Files */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 96C908361A7C6E710085C453 /* Info.plist */, 136 | ); 137 | name = "Supporting Files"; 138 | sourceTree = ""; 139 | }; 140 | /* End PBXGroup section */ 141 | 142 | /* Begin PBXNativeTarget section */ 143 | 96C908171A7C6E710085C453 /* 2015-01-31-WKWebViewDemo */ = { 144 | isa = PBXNativeTarget; 145 | buildConfigurationList = 96C9083B1A7C6E710085C453 /* Build configuration list for PBXNativeTarget "2015-01-31-WKWebViewDemo" */; 146 | buildPhases = ( 147 | 96C908141A7C6E710085C453 /* Sources */, 148 | 96C908151A7C6E710085C453 /* Frameworks */, 149 | 96C908161A7C6E710085C453 /* Resources */, 150 | ); 151 | buildRules = ( 152 | ); 153 | dependencies = ( 154 | ); 155 | name = "2015-01-31-WKWebViewDemo"; 156 | productName = "2015-01-31-WKWebViewDemo"; 157 | productReference = 96C908181A7C6E710085C453 /* 2015-01-31-WKWebViewDemo.app */; 158 | productType = "com.apple.product-type.application"; 159 | }; 160 | 96C908301A7C6E710085C453 /* 2015-01-31-WKWebViewDemoTests */ = { 161 | isa = PBXNativeTarget; 162 | buildConfigurationList = 96C9083E1A7C6E710085C453 /* Build configuration list for PBXNativeTarget "2015-01-31-WKWebViewDemoTests" */; 163 | buildPhases = ( 164 | 96C9082D1A7C6E710085C453 /* Sources */, 165 | 96C9082E1A7C6E710085C453 /* Frameworks */, 166 | 96C9082F1A7C6E710085C453 /* Resources */, 167 | ); 168 | buildRules = ( 169 | ); 170 | dependencies = ( 171 | 96C908331A7C6E710085C453 /* PBXTargetDependency */, 172 | ); 173 | name = "2015-01-31-WKWebViewDemoTests"; 174 | productName = "2015-01-31-WKWebViewDemoTests"; 175 | productReference = 96C908311A7C6E710085C453 /* 2015-01-31-WKWebViewDemoTests.xctest */; 176 | productType = "com.apple.product-type.bundle.unit-test"; 177 | }; 178 | /* End PBXNativeTarget section */ 179 | 180 | /* Begin PBXProject section */ 181 | 96C908101A7C6E710085C453 /* Project object */ = { 182 | isa = PBXProject; 183 | attributes = { 184 | LastUpgradeCheck = 0730; 185 | ORGANIZATIONNAME = tangjr; 186 | TargetAttributes = { 187 | 96C908171A7C6E710085C453 = { 188 | CreatedOnToolsVersion = 6.1.1; 189 | }; 190 | 96C908301A7C6E710085C453 = { 191 | CreatedOnToolsVersion = 6.1.1; 192 | TestTargetID = 96C908171A7C6E710085C453; 193 | }; 194 | }; 195 | }; 196 | buildConfigurationList = 96C908131A7C6E710085C453 /* Build configuration list for PBXProject "2015-01-31-WKWebViewDemo" */; 197 | compatibilityVersion = "Xcode 3.2"; 198 | developmentRegion = English; 199 | hasScannedForEncodings = 0; 200 | knownRegions = ( 201 | en, 202 | Base, 203 | ); 204 | mainGroup = 96C9080F1A7C6E710085C453; 205 | productRefGroup = 96C908191A7C6E710085C453 /* Products */; 206 | projectDirPath = ""; 207 | projectRoot = ""; 208 | targets = ( 209 | 96C908171A7C6E710085C453 /* 2015-01-31-WKWebViewDemo */, 210 | 96C908301A7C6E710085C453 /* 2015-01-31-WKWebViewDemoTests */, 211 | ); 212 | }; 213 | /* End PBXProject section */ 214 | 215 | /* Begin PBXResourcesBuildPhase section */ 216 | 96C908161A7C6E710085C453 /* Resources */ = { 217 | isa = PBXResourcesBuildPhase; 218 | buildActionMask = 2147483647; 219 | files = ( 220 | 96C908541A7C76ED0085C453 /* add_item_a.png in Resources */, 221 | 96C908271A7C6E710085C453 /* Main.storyboard in Resources */, 222 | 96C9082C1A7C6E710085C453 /* LaunchScreen.xib in Resources */, 223 | 96C908291A7C6E710085C453 /* Images.xcassets in Resources */, 224 | ); 225 | runOnlyForDeploymentPostprocessing = 0; 226 | }; 227 | 96C9082F1A7C6E710085C453 /* Resources */ = { 228 | isa = PBXResourcesBuildPhase; 229 | buildActionMask = 2147483647; 230 | files = ( 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | /* End PBXResourcesBuildPhase section */ 235 | 236 | /* Begin PBXSourcesBuildPhase section */ 237 | 96C908141A7C6E710085C453 /* Sources */ = { 238 | isa = PBXSourcesBuildPhase; 239 | buildActionMask = 2147483647; 240 | files = ( 241 | 96C908241A7C6E710085C453 /* ViewController.m in Sources */, 242 | 969AB6651A7D17C20048363E /* JSViewController.m in Sources */, 243 | 96C908211A7C6E710085C453 /* AppDelegate.m in Sources */, 244 | 96C9081E1A7C6E710085C453 /* main.m in Sources */, 245 | 96C908571A7C78E30085C453 /* BaiduViewController.m in Sources */, 246 | 96C9085A1A7C79EA0085C453 /* OSCViewController.m in Sources */, 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | }; 250 | 96C9082D1A7C6E710085C453 /* Sources */ = { 251 | isa = PBXSourcesBuildPhase; 252 | buildActionMask = 2147483647; 253 | files = ( 254 | 96C908381A7C6E710085C453 /* _015_01_31_WKWebViewDemoTests.m in Sources */, 255 | ); 256 | runOnlyForDeploymentPostprocessing = 0; 257 | }; 258 | /* End PBXSourcesBuildPhase section */ 259 | 260 | /* Begin PBXTargetDependency section */ 261 | 96C908331A7C6E710085C453 /* PBXTargetDependency */ = { 262 | isa = PBXTargetDependency; 263 | target = 96C908171A7C6E710085C453 /* 2015-01-31-WKWebViewDemo */; 264 | targetProxy = 96C908321A7C6E710085C453 /* PBXContainerItemProxy */; 265 | }; 266 | /* End PBXTargetDependency section */ 267 | 268 | /* Begin PBXVariantGroup section */ 269 | 96C908251A7C6E710085C453 /* Main.storyboard */ = { 270 | isa = PBXVariantGroup; 271 | children = ( 272 | 96C908261A7C6E710085C453 /* Base */, 273 | ); 274 | name = Main.storyboard; 275 | sourceTree = ""; 276 | }; 277 | 96C9082A1A7C6E710085C453 /* LaunchScreen.xib */ = { 278 | isa = PBXVariantGroup; 279 | children = ( 280 | 96C9082B1A7C6E710085C453 /* Base */, 281 | ); 282 | name = LaunchScreen.xib; 283 | sourceTree = ""; 284 | }; 285 | /* End PBXVariantGroup section */ 286 | 287 | /* Begin XCBuildConfiguration section */ 288 | 96C908391A7C6E710085C453 /* Debug */ = { 289 | isa = XCBuildConfiguration; 290 | buildSettings = { 291 | ALWAYS_SEARCH_USER_PATHS = NO; 292 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 293 | CLANG_CXX_LIBRARY = "libc++"; 294 | CLANG_ENABLE_MODULES = YES; 295 | CLANG_ENABLE_OBJC_ARC = YES; 296 | CLANG_WARN_BOOL_CONVERSION = YES; 297 | CLANG_WARN_CONSTANT_CONVERSION = YES; 298 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 299 | CLANG_WARN_EMPTY_BODY = YES; 300 | CLANG_WARN_ENUM_CONVERSION = YES; 301 | CLANG_WARN_INT_CONVERSION = YES; 302 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 303 | CLANG_WARN_UNREACHABLE_CODE = YES; 304 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 305 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 306 | COPY_PHASE_STRIP = NO; 307 | ENABLE_STRICT_OBJC_MSGSEND = YES; 308 | ENABLE_TESTABILITY = YES; 309 | GCC_C_LANGUAGE_STANDARD = gnu99; 310 | GCC_DYNAMIC_NO_PIC = NO; 311 | GCC_OPTIMIZATION_LEVEL = 0; 312 | GCC_PREPROCESSOR_DEFINITIONS = ( 313 | "DEBUG=1", 314 | "$(inherited)", 315 | ); 316 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 317 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 318 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 319 | GCC_WARN_UNDECLARED_SELECTOR = YES; 320 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 321 | GCC_WARN_UNUSED_FUNCTION = YES; 322 | GCC_WARN_UNUSED_VARIABLE = YES; 323 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 324 | MTL_ENABLE_DEBUG_INFO = YES; 325 | ONLY_ACTIVE_ARCH = YES; 326 | SDKROOT = iphoneos; 327 | }; 328 | name = Debug; 329 | }; 330 | 96C9083A1A7C6E710085C453 /* Release */ = { 331 | isa = XCBuildConfiguration; 332 | buildSettings = { 333 | ALWAYS_SEARCH_USER_PATHS = NO; 334 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 335 | CLANG_CXX_LIBRARY = "libc++"; 336 | CLANG_ENABLE_MODULES = YES; 337 | CLANG_ENABLE_OBJC_ARC = YES; 338 | CLANG_WARN_BOOL_CONVERSION = YES; 339 | CLANG_WARN_CONSTANT_CONVERSION = YES; 340 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 341 | CLANG_WARN_EMPTY_BODY = YES; 342 | CLANG_WARN_ENUM_CONVERSION = YES; 343 | CLANG_WARN_INT_CONVERSION = YES; 344 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 345 | CLANG_WARN_UNREACHABLE_CODE = YES; 346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 347 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 348 | COPY_PHASE_STRIP = YES; 349 | ENABLE_NS_ASSERTIONS = NO; 350 | ENABLE_STRICT_OBJC_MSGSEND = YES; 351 | GCC_C_LANGUAGE_STANDARD = gnu99; 352 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 353 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 354 | GCC_WARN_UNDECLARED_SELECTOR = YES; 355 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 356 | GCC_WARN_UNUSED_FUNCTION = YES; 357 | GCC_WARN_UNUSED_VARIABLE = YES; 358 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 359 | MTL_ENABLE_DEBUG_INFO = NO; 360 | SDKROOT = iphoneos; 361 | VALIDATE_PRODUCT = YES; 362 | }; 363 | name = Release; 364 | }; 365 | 96C9083C1A7C6E710085C453 /* Debug */ = { 366 | isa = XCBuildConfiguration; 367 | buildSettings = { 368 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 369 | FRAMEWORK_SEARCH_PATHS = ( 370 | "$(inherited)", 371 | "$(PROJECT_DIR)/2015-01-31-WKWebViewDemo", 372 | ); 373 | INFOPLIST_FILE = "2015-01-31-WKWebViewDemo/Info.plist"; 374 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 375 | PRODUCT_BUNDLE_IDENTIFIER = "com.rimi.tangjr.$(PRODUCT_NAME:rfc1034identifier)"; 376 | PRODUCT_NAME = "$(TARGET_NAME)"; 377 | }; 378 | name = Debug; 379 | }; 380 | 96C9083D1A7C6E710085C453 /* Release */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 384 | FRAMEWORK_SEARCH_PATHS = ( 385 | "$(inherited)", 386 | "$(PROJECT_DIR)/2015-01-31-WKWebViewDemo", 387 | ); 388 | INFOPLIST_FILE = "2015-01-31-WKWebViewDemo/Info.plist"; 389 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 390 | PRODUCT_BUNDLE_IDENTIFIER = "com.rimi.tangjr.$(PRODUCT_NAME:rfc1034identifier)"; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | }; 393 | name = Release; 394 | }; 395 | 96C9083F1A7C6E710085C453 /* Debug */ = { 396 | isa = XCBuildConfiguration; 397 | buildSettings = { 398 | BUNDLE_LOADER = "$(TEST_HOST)"; 399 | FRAMEWORK_SEARCH_PATHS = ( 400 | "$(SDKROOT)/Developer/Library/Frameworks", 401 | "$(inherited)", 402 | ); 403 | GCC_PREPROCESSOR_DEFINITIONS = ( 404 | "DEBUG=1", 405 | "$(inherited)", 406 | ); 407 | INFOPLIST_FILE = "2015-01-31-WKWebViewDemoTests/Info.plist"; 408 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 409 | PRODUCT_BUNDLE_IDENTIFIER = "com.rimi.tangjr.$(PRODUCT_NAME:rfc1034identifier)"; 410 | PRODUCT_NAME = "$(TARGET_NAME)"; 411 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/2015-01-31-WKWebViewDemo.app/2015-01-31-WKWebViewDemo"; 412 | }; 413 | name = Debug; 414 | }; 415 | 96C908401A7C6E710085C453 /* Release */ = { 416 | isa = XCBuildConfiguration; 417 | buildSettings = { 418 | BUNDLE_LOADER = "$(TEST_HOST)"; 419 | FRAMEWORK_SEARCH_PATHS = ( 420 | "$(SDKROOT)/Developer/Library/Frameworks", 421 | "$(inherited)", 422 | ); 423 | INFOPLIST_FILE = "2015-01-31-WKWebViewDemoTests/Info.plist"; 424 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 425 | PRODUCT_BUNDLE_IDENTIFIER = "com.rimi.tangjr.$(PRODUCT_NAME:rfc1034identifier)"; 426 | PRODUCT_NAME = "$(TARGET_NAME)"; 427 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/2015-01-31-WKWebViewDemo.app/2015-01-31-WKWebViewDemo"; 428 | }; 429 | name = Release; 430 | }; 431 | /* End XCBuildConfiguration section */ 432 | 433 | /* Begin XCConfigurationList section */ 434 | 96C908131A7C6E710085C453 /* Build configuration list for PBXProject "2015-01-31-WKWebViewDemo" */ = { 435 | isa = XCConfigurationList; 436 | buildConfigurations = ( 437 | 96C908391A7C6E710085C453 /* Debug */, 438 | 96C9083A1A7C6E710085C453 /* Release */, 439 | ); 440 | defaultConfigurationIsVisible = 0; 441 | defaultConfigurationName = Release; 442 | }; 443 | 96C9083B1A7C6E710085C453 /* Build configuration list for PBXNativeTarget "2015-01-31-WKWebViewDemo" */ = { 444 | isa = XCConfigurationList; 445 | buildConfigurations = ( 446 | 96C9083C1A7C6E710085C453 /* Debug */, 447 | 96C9083D1A7C6E710085C453 /* Release */, 448 | ); 449 | defaultConfigurationIsVisible = 0; 450 | defaultConfigurationName = Release; 451 | }; 452 | 96C9083E1A7C6E710085C453 /* Build configuration list for PBXNativeTarget "2015-01-31-WKWebViewDemoTests" */ = { 453 | isa = XCConfigurationList; 454 | buildConfigurations = ( 455 | 96C9083F1A7C6E710085C453 /* Debug */, 456 | 96C908401A7C6E710085C453 /* Release */, 457 | ); 458 | defaultConfigurationIsVisible = 0; 459 | defaultConfigurationName = Release; 460 | }; 461 | /* End XCConfigurationList section */ 462 | }; 463 | rootObject = 96C908101A7C6E710085C453 /* Project object */; 464 | } 465 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo.xcodeproj/project.xcworkspace/xcuserdata/tangjr.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saitjr/WKWebViewSimpleDemo/9869ca2cfba27c56218e24395ce5750e69455487/2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo.xcodeproj/project.xcworkspace/xcuserdata/tangjr.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo.xcodeproj/project.xcworkspace/xcuserdata/tangjr.xcuserdatad/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges 6 | 7 | SnapshotAutomaticallyBeforeSignificantChanges 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo.xcodeproj/xcuserdata/tangjr.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo.xcodeproj/xcuserdata/tangjr.xcuserdatad/xcschemes/2015-01-31-WKWebViewDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | 68 | 78 | 80 | 86 | 87 | 88 | 89 | 90 | 91 | 97 | 99 | 105 | 106 | 107 | 108 | 110 | 111 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo.xcodeproj/xcuserdata/tangjr.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 2015-01-31-WKWebViewDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 96C908171A7C6E710085C453 16 | 17 | primary 18 | 19 | 20 | 96C908301A7C6E710085C453 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 2015-01-31-WKWebViewDemo 4 | // 5 | // Created by TangJR on 15/1/31. 6 | // Copyright (c) 2015年 tangjr. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // 2015-01-31-WKWebViewDemo 4 | // 5 | // Created by TangJR on 15/1/31. 6 | // Copyright (c) 2015年 tangjr. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 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 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/BaiduViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DetailViewController.h 3 | // 2015-01-31-WKWebViewDemo 4 | // 5 | // Created by TangJR on 15/1/31. 6 | // Copyright (c) 2015年 tangjr. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BaiduViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/BaiduViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DetailViewController.m 3 | // 2015-01-31-WKWebViewDemo 4 | // 5 | // Created by TangJR on 15/1/31. 6 | // Copyright (c) 2015年 tangjr. All rights reserved. 7 | // 8 | 9 | #import "BaiduViewController.h" 10 | #import 11 | 12 | #define k_JSBIN_URL @"http://jsbin.com/meniw" 13 | 14 | @interface BaiduViewController () 15 | 16 | @property (strong, nonatomic) WKWebView *webView; 17 | 18 | @end 19 | 20 | @implementation BaiduViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | // Do any additional setup after loading the view. 25 | 26 | _webView = [[WKWebView alloc] initWithFrame:self.view.bounds]; 27 | _webView.UIDelegate = self; 28 | _webView.navigationDelegate = self; 29 | [self.view addSubview:_webView]; 30 | 31 | [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.baidu.com"]]]; 32 | } 33 | 34 | #pragma mark - WKNavigationDelegate 35 | 36 | /** 37 | * 页面开始加载时调用 38 | * 39 | * @param webView 实现该代理的webview 40 | * @param navigation 当前navigation 41 | */ 42 | - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation { 43 | 44 | NSLog(@"%s", __FUNCTION__); 45 | } 46 | 47 | /** 48 | * 当内容开始返回时调用 49 | * 50 | * @param webView 实现该代理的webview 51 | * @param navigation 当前navigation 52 | */ 53 | - (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation { 54 | 55 | NSLog(@"%s", __FUNCTION__); 56 | } 57 | 58 | /** 59 | * 页面加载完成之后调用 60 | * 61 | * @param webView 实现该代理的webview 62 | * @param navigation 当前navigation 63 | */ 64 | - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { 65 | 66 | NSLog(@"%s", __FUNCTION__); 67 | } 68 | 69 | /** 70 | * 加载失败时调用 71 | * 72 | * @param webView 实现该代理的webview 73 | * @param navigation 当前navigation 74 | * @param error 错误 75 | */ 76 | - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error { 77 | 78 | NSLog(@"%s", __FUNCTION__); 79 | } 80 | 81 | /** 82 | * 接收到服务器跳转请求之后调用 83 | * 84 | * @param webView 实现该代理的webview 85 | * @param navigation 当前navigation 86 | */ 87 | - (void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation { 88 | 89 | NSLog(@"%s", __FUNCTION__); 90 | } 91 | 92 | /** 93 | * 在收到响应后,决定是否跳转 94 | * 95 | * @param webView 实现该代理的webview 96 | * @param navigationResponse 当前navigation 97 | * @param decisionHandler 是否跳转block 98 | */ 99 | - (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler { 100 | 101 | // 如果响应的地址是百度,则允许跳转 102 | if ([navigationResponse.response.URL.host.lowercaseString isEqual:@"www.baidu.com"]) { 103 | 104 | // 允许跳转 105 | decisionHandler(WKNavigationResponsePolicyAllow); 106 | return; 107 | } 108 | // 不允许跳转 109 | decisionHandler(WKNavigationResponsePolicyCancel); 110 | } 111 | 112 | /** 113 | * 在发送请求之前,决定是否跳转 114 | * 115 | * @param webView 实现该代理的webview 116 | * @param navigationAction 当前navigation 117 | * @param decisionHandler 是否调转block 118 | */ 119 | - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { 120 | 121 | // 如果请求的是百度地址,则延迟5s以后跳转 122 | if ([navigationAction.request.URL.host.lowercaseString isEqual:@"www.baidu.com"]) { 123 | 124 | // // 延迟5s之后跳转 125 | // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 126 | // 127 | // // 允许跳转 128 | // decisionHandler(WKNavigationActionPolicyAllow); 129 | // }); 130 | 131 | // 允许跳转 132 | decisionHandler(WKNavigationActionPolicyAllow); 133 | return; 134 | } 135 | // 不允许跳转 136 | decisionHandler(WKNavigationActionPolicyCancel); 137 | } 138 | 139 | @end -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 29 | 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 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSAllowsArbitraryLoads 28 | 29 | 30 | UILaunchStoryboardName 31 | LaunchScreen 32 | UIMainStoryboardFile 33 | Main 34 | UIRequiredDeviceCapabilities 35 | 36 | armv7 37 | 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/JSViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // JSViewController.h 3 | // 2015-01-31-WKWebViewDemo 4 | // 5 | // Created by TangJR on 15/1/31. 6 | // Copyright (c) 2015年 tangjr. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface JSViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/JSViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // JSViewController.m 3 | // 2015-01-31-WKWebViewDemo 4 | // 5 | // Created by TangJR on 15/1/31. 6 | // Copyright (c) 2015年 tangjr. All rights reserved. 7 | // 8 | 9 | #import "JSViewController.h" 10 | #import 11 | 12 | #define HTML @"" 13 | 14 | @interface JSViewController () 15 | 16 | @property (strong, nonatomic) WKWebView *webView; 17 | 18 | - (IBAction)refreshButtonPressed:(id)sender; 19 | 20 | @end 21 | 22 | @implementation JSViewController 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | // Do any additional setup after loading the view. 27 | 28 | // 图片缩放的js代码 29 | NSString *js = @"var count = document.images.length;for (var i = 0; i < count; i++) {var image = document.images[i];image.style.width=320;};window.alert('找到' + count + '张图');"; 30 | 31 | // 根据JS字符串初始化WKUserScript对象 32 | WKUserScript *script = [[WKUserScript alloc] initWithSource:js injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES]; 33 | 34 | // 根据生成的WKUserScript对象,初始化WKWebViewConfiguration 35 | WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init]; 36 | [config.userContentController addUserScript:script]; 37 | 38 | _webView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:config]; 39 | _webView.UIDelegate = self; 40 | _webView.navigationDelegate = self; 41 | [_webView loadHTMLString:@"" baseURL:nil]; 42 | [self.view addSubview:_webView]; 43 | } 44 | 45 | #pragma mark - WKUIDelegate 46 | 47 | /** 48 | * web界面中有弹出警告框时调用 49 | * 50 | * @param webView 实现该代理的webview 51 | * @param message 警告框中的内容 52 | * @param frame 主窗口 53 | * @param completionHandler 警告框消失调用 54 | */ 55 | 56 | - (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL))completionHandler { 57 | [[[UIAlertView alloc] initWithTitle:@"温馨提示" message:message delegate:nil cancelButtonTitle:@"确认" otherButtonTitles: nil] show]; 58 | 59 | completionHandler(YES); 60 | } 61 | 62 | - (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString *))completionHandler { 63 | 64 | 65 | } 66 | 67 | // 从web界面中接收到一个脚本时调用 68 | - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message { 69 | 70 | NSLog(@"%@", message); 71 | } 72 | 73 | #pragma mark - Button Pressed 74 | 75 | - (IBAction)refreshButtonPressed:(id)sender { 76 | 77 | [_webView reload]; 78 | } 79 | 80 | @end -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/OSCViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // OSCViewController.h 3 | // 2015-01-31-WKWebViewDemo 4 | // 5 | // Created by TangJR on 15/1/31. 6 | // Copyright (c) 2015年 tangjr. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface OSCViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/OSCViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // OSCViewController.m 3 | // 2015-01-31-WKWebViewDemo 4 | // 5 | // Created by TangJR on 15/1/31. 6 | // Copyright (c) 2015年 tangjr. All rights reserved. 7 | // 8 | 9 | #import "OSCViewController.h" 10 | #import 11 | 12 | @interface OSCViewController () 13 | 14 | @property (strong, nonatomic) WKWebView *webView; 15 | 16 | @end 17 | 18 | @implementation OSCViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | // Do any additional setup after loading the view. 23 | 24 | _webView = [[WKWebView alloc] initWithFrame:self.view.bounds]; 25 | [self.view addSubview:_webView]; 26 | 27 | [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.oschina.net/"]]]; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 2015-01-31-WKWebViewDemo 4 | // 5 | // Created by TangJR on 15/1/31. 6 | // Copyright (c) 2015年 tangjr. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // 2015-01-31-WKWebViewDemo 4 | // 5 | // Created by TangJR on 15/1/31. 6 | // Copyright (c) 2015年 tangjr. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view, typically from a nib. 22 | 23 | } 24 | 25 | @end -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/add_item_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saitjr/WKWebViewSimpleDemo/9869ca2cfba27c56218e24395ce5750e69455487/2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/add_item_a.png -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 2015-01-31-WKWebViewDemo 4 | // 5 | // Created by TangJR on 15/1/31. 6 | // Copyright (c) 2015年 tangjr. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /2015-01-31-WKWebViewDemo/2015-01-31-WKWebViewDemoTests/_015_01_31_WKWebViewDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // _015_01_31_WKWebViewDemoTests.m 3 | // 2015-01-31-WKWebViewDemoTests 4 | // 5 | // Created by TangJR on 15/1/31. 6 | // Copyright (c) 2015年 tangjr. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface _015_01_31_WKWebViewDemoTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation _015_01_31_WKWebViewDemoTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WKWebViewSimpleDemo 2 | iOS8中WebKit库中的WKWebView简单使用方法,包括初始化,最基础的代理方法,以及JS加载。 3 | 技术支持网站:http://www.brighttj.com/ios/ios-wkwebview-new-features-and-use.html 4 | --------------------------------------------------------------------------------