1、UIWebDocumentView
2、WebView
3、
//================================================================//
私有框架所在目录?
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/PrivateFrameworks
//================================================================//
UIWebView 的层次
①、UIScrollView is a subview of UIWebView
②、UIWebDocumentView is a subview of UIScrollView
//================================================================//
如何获取 UIWebDocumentView 与 WebView ?
UIWebView *officialWebView = [[UIWebView alloc] init];
UIWebDocumentView *webDocumentView = nil;
id webView = nil;
webDocumentView = objc_msgSend(officialWebView, @selector(_documentView));
object_getInstanceVariable(webDocumentView, "_webView", (void**)&webView);
具体有支持哪些消息可以从网络上查找,有dump出的头文件供下载。
//================================================================//
如何截获 Touch 事件?
@implementation UIView (__TapHook)
- (void)__replacedTouchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
[self __replacedTouchesBegan:touches withEvent:event];
if( [self.superview.superview isMemberOfClass:[UICWebView class]] ) {
[(UICWebView*)self.superview.superview hookedTouchesBegan:touches withEvent:event];
}
}
@end
+ (void)installHook {
Class klass = objc_getClass( "UIWebDocumentView" );
// replace touch began event
method_exchangeImplementations(
class_getInstanceMethod(klass, @selector(touchesBegan:withEvent:)),
class_getInstanceMethod(klass, @selector(__replacedTouchesBegan:withEvent:)) );
}
ref:http://sonson-code.googlecode.com/svn/trunk/iPhone2.0/UICWebView/
//================================================================//
如何获取网页的真实加载速度?
①、注册通知:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(progressEstimateChanged:)
name:WebViewProgressEstimateChangedNotification
object:coreWebView];
②、处理通知消息:
- (void)progressEstimateChanged:(NSNotification*)theNotification {
// You can get the progress as a float with
// [[theNotification object] estimatedProgress], and then you
// can set that to a UIProgressView if you'd like.
// theProgressView is just an example of what you could do.
[theProgressView setProgress:[[theNotification object] estimatedProgress]];
if ((int)[[theNotification object] estimatedProgress] == 1) {
theProgressView.hidden = TRUE;
// Hide the progress view. This is optional, but depending on where
// you put it, this may be a good idea.
// If you wanted to do this, you'd
// have to set theProgressView to visible in your
// webViewDidStartLoad delegate method,
// see Apple's UIWebView documentation.
}
}
ref:http://winxblog.com/2009/02/iphone-uiwebview-estimated-progress/
//================================================================//
调试 UIWebView
ref:http://www.idryman.org/blog/2012/06/17/debug-uiwebview-in-your-ios-app/
ref:http://atnan.com/blog/2011/11/17/enabling-remote-debugging-via-private-apis-in-mobile-safari/
//================================================================//
开启并使用 WebGL
ref:http://atnan.com/blog/2011/11/03/enabling-and-using-webgl-on-ios/
//================================================================//