如何以编程方式点击状态栏后触发“scrollsToTop”?

时间:2012-02-29 14:45:58

标签: iphone uiscrollview tableview

如果用户点击导航栏标题,我想触发当您以编程方式点击状态栏时触发的scrollsToTop函数。

这是我目前的方法。

[tableView_ setContentOffset:CGPointMake(0, 0) animated:YES];
[tableView_ flashScrollIndicators];

但是,它没有动画ScrollIndicators,就像你点击状态栏滚动到顶部。

任何帮助将不胜感激,谢谢!

3 个答案:

答案 0 :(得分:1)

尝试类似

的内容
-(void)doScroll{
    void (^scroll)(void) = ^{
        [contentTableView setContentOffset:CGPointMake(0, 0) animated:NO];
        [contentTableView flashScrollIndicators];
    };

    [UIView animateWithDuration:0.5 animations:scroll];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self performSelector:@selector(doScroll) withObject:nil afterDelay:1];
}

答案 1 :(得分:1)

您是否尝试将-setContentOffset:animated与UIScrollViewDelegate方法- (void)scrollViewDidScrollToTop:和/或-(void)scrollViewDidEndScrollingAnimation:结合使用?

您可以将-flashScrollIndicators发送到其中一个而不是依赖于计时器,即使用-performSelector:withObject:afterDelay。)

答案 2 :(得分:0)

在网络视图的ShouldStartLoadWithRequest委托方法中尝试此操作

    ((UIScrollView *)[[self.challengeWebView subviews] objectAtIndex:0]).scrollsToTop = NO;
相关问题