ios - 在 UITableView 中插入一些行后,它不会在 ios 7 中滚动

标签 ios iphone uitableview ios7

您好,我已经创建了 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];

最佳答案

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

-(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/

相关文章:

iphone - iOS 应用程序更新 - CFBundleShortVersionString 和 CFBundleVersion

ios - 如何更改 uiscrollview ios 中滚动指示器的宽度?

iphone - 如果我调用此方法,则会收到错误 "database is lock"。我该如何解决这个问题?请帮我

iphone - 如何在 Iphone 中调用 Magento API 登录方法

ios - 带有 2 个动画的 insertRowsAtIndexPaths

ios - 如果 UITableView 中的字符串/对象为空,如何隐藏标题

iPhone:didSelectRowAtIndexPath 未调用

ios - 在 segue 期间从 UINavigationController 的导航堆栈中删除 View Controller ?

objective-c - DATAGridViewCell 自定义 View 按钮操作方法未被调用?

iphone - 如何从上传的 iPhone 照片中获取正确的纬度和经度?