2013-08-03 13 views
2

我用的UIWebView來撰寫電子郵件
的UIWebView的內容包含的內容:處理事件的內容的UIWebView改變

<html>  
     <body> 
      <div id="content" contenteditable="true" style="font-family: Helvetica; margin-top:15px;"> 
      </div> 
     </body> 
</html> 

我需要處理的事件內容的UIWebView變化來調整幀的UIWebView?

+0

我只是提出了一個建議,但我不能完全肯定它是否工作。讓我知道如果它不。 –

回答

1

你可以嘗試使用志願:

// Put this where you create your UIWebView 
[self.webView addObserver:self forKeyPath:@"scrollView.contentSize" options:NSKeyValueObservingOptionNew context:@selector(observeValueForKeyPath:ofObject:change:context:)]; 

// Put this somewhere in the same file 
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 
    if([keyPath isEqualToString:@"scrollView.contentSize"]) { 
     // Ensure the web view can fit its content 
     self.webView.frame = (CGRect) { 
      self.webView.frame.origin, 
      self.webView.scrollView.contentSize 
     }; 
    } 
} 
相關問題