<small id='tu6I9'></small><noframes id='tu6I9'>

    <tfoot id='tu6I9'></tfoot>
    • <bdo id='tu6I9'></bdo><ul id='tu6I9'></ul>

    1. <i id='tu6I9'><tr id='tu6I9'><dt id='tu6I9'><q id='tu6I9'><span id='tu6I9'><b id='tu6I9'><form id='tu6I9'><ins id='tu6I9'></ins><ul id='tu6I9'></ul><sub id='tu6I9'></sub></form><legend id='tu6I9'></legend><bdo id='tu6I9'><pre id='tu6I9'><center id='tu6I9'></center></pre></bdo></b><th id='tu6I9'></th></span></q></dt></tr></i><div id='tu6I9'><tfoot id='tu6I9'></tfoot><dl id='tu6I9'><fieldset id='tu6I9'></fieldset></dl></div>
    2. <legend id='tu6I9'><style id='tu6I9'><dir id='tu6I9'><q id='tu6I9'></q></dir></style></legend>

        如何在表格单元格中使用 UIWebView?

        时间:2023-10-22
      1. <tfoot id='FyKyr'></tfoot>

              <i id='FyKyr'><tr id='FyKyr'><dt id='FyKyr'><q id='FyKyr'><span id='FyKyr'><b id='FyKyr'><form id='FyKyr'><ins id='FyKyr'></ins><ul id='FyKyr'></ul><sub id='FyKyr'></sub></form><legend id='FyKyr'></legend><bdo id='FyKyr'><pre id='FyKyr'><center id='FyKyr'></center></pre></bdo></b><th id='FyKyr'></th></span></q></dt></tr></i><div id='FyKyr'><tfoot id='FyKyr'></tfoot><dl id='FyKyr'><fieldset id='FyKyr'></fieldset></dl></div>

              <small id='FyKyr'></small><noframes id='FyKyr'>

                <legend id='FyKyr'><style id='FyKyr'><dir id='FyKyr'><q id='FyKyr'></q></dir></style></legend>
                  <tbody id='FyKyr'></tbody>
                • <bdo id='FyKyr'></bdo><ul id='FyKyr'></ul>
                  本文介绍了如何在表格单元格中使用 UIWebView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在构建一个包含一些 HTML 文本的表格,因此我使用 UIWebView 作为我的自定义表格单元格的子视图.我已经遇到了一个问题——当我在表格中向下滚动时,UIWebViews 需要一秒钟才能更新.例如,我将查看编号为 1、2 和 3 的行的单元格.我会向下滚动到 8、9 和 10.有一会儿,在单元格 #8 中可见的 UIWebView 的内容是单元格#1 中的内容,单元格#9 中的内容是单元格#2 中的内容,依此类推.

                  I'm building a table with some text that is HTML, so I am using a UIWebView as a subview of my custom table cells. I already ran into one problem - as I scrolled down in the table, it would take the UIWebViews a second to update. For example, I'd be viewing Cells at rows numbered 1, 2, and 3. I'd scroll down to say 8, 9, and 10. For a moment, the content of the UIWebView that was visible in cell #8 was the content from cell #1, the content in cell #9 was that from cell #2, and so on.

                  我了解到问题在于 UIWebView 只是缓慢地呈现它们的文本.建议尽快将内容预加载到 UIWebView 中,而不是等到表接收到 cellForRowAtIndexPath.所以现在,我有一个域对象,它之前只有 WebView 的文本内容 - 但现在它实际上有对 UIWebView 本身的引用.

                  I learned that the problem was that UIWebViews simply render their text slowly. It was suggested to instead preload the content into the UIWebView as soon as I could instead of waiting until the table receives the cellForRowAtIndexPath. So now, I have a Domain Object which before just had the text content of the WebView - but now it actually has a reference to the UIWebView itself.

                  但现在 UIWebView 中的一些内容呈现,当我滚动表格时 UIWebView 仅显示为灰色框.如果我触摸灰色框,它实际上会接收触摸并更新 WebView - 例如,如果我触摸一个链接(我可能会或可能不会这样做,因为该框是灰色的,而且很幸运),链接到的页面将被请求并正确显示.

                  But now some of the content in the UIWebView renders, and when I scroll through the table the UIWebView shows only as a grey box. If I touch the grey box, it will actually receive the touch and update the WebView - for example if I touch a link (which I may or may not do, since the box is gray and it would be by a stroke of luck), the page that was linked to will be requested and displayed properly.

                  - (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
                  if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
                              // I suppose this isn't necessary since I am just getting it from the
                              // Domain Object anyway
                      content = [[UIWebView alloc] initWithFrame:CGRectZero];
                      content.backgroundColor = [UIColor blackColor];
                      [self addSubview:content];
                      [content release];
                  }
                  return self;
                  }
                  
                  // called by cellForRowAtIndexPath 
                  - (void)setMyDomainObject:(MyDomainObject*)anObject {
                  UIWebView *contentWebView = anObject.contentWebView;
                  int contentIndex = [self.subviews indexOfObject:content];
                  [self insertSubview:contentWebView atIndex:contentIndex];
                  }
                  

                  推荐答案

                  解决这个问题的一种方法是使用多个 UILabel,每个 UILabel 都有不同的字体.然后策略性地将它们放置在单元格中,使它们看起来像连续的文本.我已经在 UITableView 中看到了这一点,效果非常好.

                  One way to deal with this would be to use several UILabels, each with different fonts. Then strategically place them within the cell as to make them seem like contiguous text. I've seen this done in a UITableView with very good results.

                  另一个性能问题可能是您覆盖了 UItableViewCell 及其 init 方法.这几乎总是会导致 UITableView 的性能不佳.相反,只需使用常规 UITableViewCell 实例并将子视图添加到它的 contentView.

                  Another performance problem may be that you are overiding UItableViewCell and it's init method. This almost always leads to poor performance in a UITableView. Instead just use the regular UITableViewCell instances and add subviews to it's contentView.

                  Matt Gallagher 的 Easy Custom UITableView Drawing.

                  This has been covered extensively by Matt Gallagher's Easy Custom UITableView Drawing.

                  描述的另一种方法是使用 Three20,它也可以为您提供样式文本.

                  Another method described was to use Three20, which can give you styled text as well.

                  您目前正在尝试的操作无法通过 UIWebview 完成.

                  What you are attempting currently can't be done with UIWebview.

                  预加载无济于事:当 UIWebview 在屏幕外渲染时,这会减慢 UI;你应该经常在 iPhone 上练习延迟加载.

                  Preloading won't help: this would slow down the UI when UIWebviews are being rendered offscreen; you should always practice lazy loading on the iPhone.

                  将 UIWebviews 放入 UITableView 会带来潜在的不可接受的性能损失.您将需要使用其他方式来实现您的目标.

                  Putting UIWebviews in a UITableView will come with a potentially unacceptable performance hit. You will need to use other means to accomplish your goal.

                  很遗憾,NSAttributedString 在 UIKit 中不可用,这可以轻松解决您的问题.

                  Unfortunately, NSAttributedString is unavailable in UIKit, which could easily solve your problem.

                  这篇关于如何在表格单元格中使用 UIWebView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:iOS - WKWebView 跨源请求仅支持 HTTP 下一篇:使用 UIWebView 时奇怪的填充/边距

                  相关文章

                  <tfoot id='ZsecS'></tfoot>

                  <legend id='ZsecS'><style id='ZsecS'><dir id='ZsecS'><q id='ZsecS'></q></dir></style></legend>
                • <small id='ZsecS'></small><noframes id='ZsecS'>

                      <bdo id='ZsecS'></bdo><ul id='ZsecS'></ul>
                      <i id='ZsecS'><tr id='ZsecS'><dt id='ZsecS'><q id='ZsecS'><span id='ZsecS'><b id='ZsecS'><form id='ZsecS'><ins id='ZsecS'></ins><ul id='ZsecS'></ul><sub id='ZsecS'></sub></form><legend id='ZsecS'></legend><bdo id='ZsecS'><pre id='ZsecS'><center id='ZsecS'></center></pre></bdo></b><th id='ZsecS'></th></span></q></dt></tr></i><div id='ZsecS'><tfoot id='ZsecS'></tfoot><dl id='ZsecS'><fieldset id='ZsecS'></fieldset></dl></div>