Permalink
Browse files

changed for UIWebView.

  • Loading branch information...
1 parent 42a5bf0 commit a92e13c0db0b78c855bab06d1afb6c5767b04509 @kishikawakatsumi committed Feb 8, 2009
Showing with 9 additions and 2 deletions.
  1. +9 −2 Classes/WebViewController.m
View
11 Classes/WebViewController.m
@@ -4,6 +4,7 @@
#import "HUDMessageView.h"
#import "JSON/JSON.h"
#import "Debug.h"
+#import <objc/runtime.h>
@implementation WebViewController
@@ -13,6 +14,10 @@ @implementation WebViewController
@synthesize pageURL;
@synthesize lastPageURL;
+static NSObject *webViewcreateWebViewWithRequestIMP(id self, SEL _cmd, NSObject* sender, NSObject* request) {
+ return [sender retain];
+}
+
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
UIBarButtonItem *commentButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Comment.png"]
@@ -157,8 +162,7 @@ - (void)webViewDidFinishLoad:(UIWebView *)aWebView {
backButton.enabled = (webView.canGoBack) ? YES : NO;
forwardButton.enabled = (webView.canGoForward) ? YES : NO;
- self.title = [aWebView stringByEvaluatingJavaScriptFromString:
- @"try {var a = document.getElementsByTagName('a'); for (var i = 0; i < a.length; ++i) { a[i].setAttribute('target', '');}}catch (e){}; document.title"];
+ self.title = [aWebView stringByEvaluatingJavaScriptFromString:@"document.title"];
LOG_CURRENT_METHOD;
}
@@ -178,6 +182,9 @@ - (void)webView:(UIWebView *)aWebView didFailLoadWithError:(NSError *)error {
- (void)viewDidLoad {
[super viewDidLoad];
[webView setBackgroundColor:[UIColor whiteColor]];
+ Class UIWebViewWebViewDelegate = objc_getClass("UIWebViewWebViewDelegate");
+ class_addMethod(UIWebViewWebViewDelegate, @selector(webView:createWebViewWithRequest:),
+ (IMP)webViewcreateWebViewWithRequestIMP, "@@:@@");
}
- (void)viewWillAppear:(BOOL)animated {

0 comments on commit a92e13c

Please sign in to comment.