<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?

        How do I use a UIWebView in a Table Cell?(如何在表格单元格中使用 UIWebView?)
      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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
                  Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))
                  Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
                  Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)
                  [ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)

                  <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>
                              <tbody id='ZsecS'></tbody>