菜鸟教程小白 发表于 2022-12-12 13:21:09

ios - 处理事件内容 UIWebview 变化


                                            <p><p>我使用 UIWebview 撰写邮件内容<br/>
UIWebview 包含内容:</p>

<pre><code>&lt;html&gt;   
      &lt;body&gt;
            &lt;div id=&#34;content&#34; contenteditable=&#34;true&#34; style=&#34;font-family: Helvetica; margin-top:15px;&#34;&gt;
            &lt;/div&gt;
      &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>我需要处理事件内容 UIWebview 更改来调整 UIWebview 框架的大小吗?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您可以尝试使用 KVO:</p>

<pre><code>// Put this where you create your UIWebView
;

// Put this somewhere in the same file
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
    if( ) {
      // Ensure the web view can fit its content
      self.webView.frame = (CGRect) {
            self.webView.frame.origin,
            self.webView.scrollView.contentSize
      };
    }
}
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 处理事件内容 UIWebview 变化,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/18028918/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/18028918/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 处理事件内容 UIWebview 变化