2012-01-30 31 views
4

iPhoneアプリのリッチテキストエディタ(テキストの整列、フォント、太字、斜体、下線など)を作成する必要があります。データをHTMLとして保存し、UIWebViewでレンダリングすることについて聞いたことがあります。ユーザーがデータを編集できるようにしたいのですが、私のアプリケーションでTapContentWindowを使用してUIWebViewのタッチを検出しています(詳細はhere)。iPhone用のwebviewのリッチテキストエディタ

- (id)init { 
    self = [super init]; 
    if (self) { 
      tapDetectingWindow = (TapDetectingWindow *)[[UIApplication sharedApplication].windows objectAtIndex:0]; //mWindow, variable reference to TapDetectingWindow 
     tapDetectingWindow.viewToObserve = webView; 
     tapDetectingWindow.controllerThatObserves = self;  

     webView = [[UIWebView alloc] init]; 
     [webView setFrame:CGRectMake(0, 0, 340, 1900)]; 
     [webView setTag:1]; 
     [webView addSubview:keyboardText]; 
     [webView setDelegate:self]; 
     [webView setOpaque:0.0]; 

     [webView loadHTMLString:htmlString baseURL:NULL]; 
     [self.view addSubview:webView]; 

     keyboardText = [[UITextField alloc] init]; 
     keyboardText.autocorrectionType = UITextAutocorrectionTypeNo; 
     [keyboardText setDelegate:self]; 
     [self.view addSubview:keyboardText]; 
    } 
    return self; 
} 

しかし、私のアプリはメッセージ

tapDetectingWindow.viewToObserve = webView 

と髪を引っ張っの数時間後にレポート

* -[UIWindow setViewToObserve:]: unrecognized selector sent to instance 0x4a26b90 

答えて

3

と、クラッシュされ、ここでの答えです:あなたはあなたのを編集する必要がありますAppDelegateの.mファイルを使用してTapDetectingWindowを正しく動作させる:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    UIViewController* vc = self.window.rootViewController; 
    self.window = [[TapDetectingWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    self.window.rootViewController = vc; 

    return YES;  
} 

私はこれを試しましたが、それはTapDetectingWindowチュートリアルの残りの部分と完全に動作しています!

関連する問題