我是iOS的新手,并且遇到有关自动滚动表格视图单元格的问题。
我正在使用这样的代码

- (void)viewDidAppear:(BOOL)animated{

  [table setContentOffset:CGPointMake(0.0, table.contentSize.height - table.bounds.size.height)
                 animated:YES];

  [tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[headarray count]-1 inSection:0]
                   atScrollPosition:UITableViewScrollPositionBottom
                           animated:YES];
}


但这表明我无法访问此代码中我做错的事情。谢谢!

我在connectionDidFinishLoading方法中尝试了这样的代码

if ([headarray count] != 0) {

            NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[headarray count]-1 inSection:0];
            [Newstable scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:NO];
        }

最佳答案

查看此链接https://github.com/danielamitay/DAAutoScroll。您可以使用这些类自动滚动表视图。
1.进口舱

导入“ DAAutoScroll.h”

- (void)viewDidLoad {
    [self performSelector:@selector(scrollDown) withObject:self afterDelay:3.0];
}

-(void)scrollDown{

    yourtableview.scrollPointsPerSecond = 20.0f;
    [yourtableview startScrolling];

}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    if (!decelerate) {
        [yourtableview startScrolling];
    }
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    [yourtableview startScrolling];
}

关于ios - 如何在Objective C中自动滚动“定制表 View ”单元格,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41561673/

10-12 23:26