OGeek|极客世界-中国程序员成长平台

标题: ios - 在 UITableView 中插入一些行后,它在 ios 7 中没有滚动 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 17:17
标题: ios - 在 UITableView 中插入一些行后,它在 ios 7 中没有滚动

您好,我已经创建了 UITableView。在 Touch of it 单元格上,我在其中插入更多行。在 UITableView 中插入更多行后,滚动不起作用。这只发生在 ios 7 中。

有人遇到过这个问题吗?

这是插入的代码。

NSArray *rowIndex = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:1 inSection:[self.lastSelectedIndex section]]];
[self.table beginUpdates];
[self.table insertRowsAtIndexPaths:rowIndex withRowAnimation:UITableViewRowAnimationNone];
[self.table endUpdates];



Best Answer-推荐答案


我不确定您的代码发生了什么,但是如果您想在每个添加行之后滚动,只需调用下面的方法(注意:- 根据您的变量名称修改代码)

-(void)goToBottom
{
     NSInteger lastSectionIndex = MAX(0, [myTableName numberOfSections] - 1);
     NSInteger lastRowIndex = MAX(0, [ myTableName numberOfRowsInSection:lastSectionIndex] - 1);

     NSIndexPath *lastIndexPath = [NSIndexPath indexPathForRow:lastRowIndex inSection:lastSectionIndex];

   if([myArray count] > 0)
    {
        [myTableName scrollToRowAtIndexPath:lastIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
    }

}

关于ios - 在 UITableView 中插入一些行后,它在 ios 7 中没有滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20651403/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4