繁体   English   中英

如何在Objective C中自动滚动“定制表视图”单元格

[英]How to autoscroll Custom Table View cell in Objective C

我是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];
}
[tableviewname setContentOffset:CGPointMake(0, ([arrayofcontact count]-10)*cellheight) animated:YES];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM