<legend id='S0Nzj'><style id='S0Nzj'><dir id='S0Nzj'><q id='S0Nzj'></q></dir></style></legend>

    1. <tfoot id='S0Nzj'></tfoot>

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

      • <bdo id='S0Nzj'></bdo><ul id='S0Nzj'></ul>

        从底部加载 UITableView

        时间:2023-05-30
      1. <legend id='h6FOo'><style id='h6FOo'><dir id='h6FOo'><q id='h6FOo'></q></dir></style></legend>

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

                • <small id='h6FOo'></small><noframes id='h6FOo'>

                • 本文介绍了从底部加载 UITableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在尝试使用 UITableView 来模仿 iMessage 气泡文本行为.为了始终滚动到底部,我在 viewDidLoadviewDidAppear 时使用了 scrollToRowAtIndexPath.这是因为当调用 viewDidLoad 方法时,表格还没有完全加载,所以我需要在 viewDidAppear 中额外滚动.这段代码成功了.但是,我想要的不是动画滚动(将 animated 设置为 NO 并不能解决此问题),我希望表格始终从底部显示,而不是加载表,然后转到最后一行.

                  I'm trying to mimic the iMessage bubble text behaviour with an UITableView. In order to always scroll to the bottom I'm using scrollToRowAtIndexPath when viewDidLoad and viewDidAppear. This is because when the viewDidLoad method is called, the table has not been completely loaded, so I need that extra scroll in viewDidAppear. This code makes the trick. However, what I want is not an animated scroll (setting animated to NO does not solve this), I want the table to be displayed always from the bottom, not load the table and then go to the last row.

                  这可能吗?我找不到任何完全符合所需行为的解决方案.

                  Is this possible? I can't find any solution that fits completely with the desired behaviour.

                  推荐答案

                  您可以避免从 viewDidLoad 调用,因为从 viewDidAppear 中滚动会使第一次调用变得多余.每次导航回视图时都会调用 viewDidAppear,但视图初始化时只会调用一次 viewDidLoad.

                  You can avoid the call from viewDidLoad because scrolling from within viewDidAppear makes that first call redundant. viewDidAppear is called every time you navigate back to the view but viewDidLoad is only called once when the view is initialized.

                  我同意之前关于向用户隐藏滚动而不是更改 UITableView 加载数据的方式的建议.我的建议是在 viewWillAppear 方法中使用 scrollToRowAtIndexPath 方法,并将动画设置为 NO.之后,如果您必须在表格对用户可见时添加新行,请使用 insertRowsAtIndexPaths:withRowAnimation: 在表格视图底部添加一行.请务必注意在数据模型的末尾添加数据,以便当用户离开并返回时,他/她会回到相同的布局.

                  I would agree with earlier suggestions of hiding the scroll from the user instead of changing the way a UITableView is loading data. My suggestion would be to use the scrollToRowAtIndexPath method in the viewWillAppear method with animation set to NO. After that if you have to add a new row while the table is visible to the user, use insertRowsAtIndexPaths:withRowAnimation: to add a row at the bottom of the table view. Be sure to take care of adding the data at the end of your data model so that when the user navigates away and comes back, s/he comes back to the same layout.

                  希望这会有所帮助.

                  刚刚看到您不接受先前答案的原因,并认为我会再详细说明一下.我提出的解决方案需要最少的努力,避免一次又一次地调用 reloadData ,从而避免一次又一次地调用 scrollToRowAtIndexPath 方法.您只需在 viewWillAppear 中调用一次 scrollToRowAtIndexPath 即可滚动到表格视图的底部(这样做时向用户隐藏转换),您无需再次这样做.

                  edit: Just saw your reason for not accepting the previous answers and thought I'd elaborate a little more. The solution I propose would require minimum effort, avoid calling reloadData time and again and thus avoid calling the scrollToRowAtIndexPath method again and again. You only need to make one call to scrollToRowAtIndexPath in viewWillAppear to scroll to the bottom of the table view (hiding the transition from the user when doing so) and you wouldn't need to do that again.

                  这篇关于从底部加载 UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在不增加背景图像大小的情况下增加(自定义 下一篇:有条件地包含不同 iOS SDK 版本的库?

                  相关文章

                  最新文章

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

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

                        <bdo id='XbQwM'></bdo><ul id='XbQwM'></ul>
                      <legend id='XbQwM'><style id='XbQwM'><dir id='XbQwM'><q id='XbQwM'></q></dir></style></legend>