Ios Bounce UIScrollView-提示有';更多
我正在开发一个带有滚动视图的应用程序。现在还不清楚是否有更多的内容,并且没有滚动指示器(滚动视图已分页) 因此,为了给用户一个‘嘿,这里有东西……’,我想让滚动视图在启动时做一个微妙的向下反弹,然后向上反弹。我试过这个:Ios Bounce UIScrollView-提示有';更多,ios,uiscrollview,Ios,Uiscrollview,我正在开发一个带有滚动视图的应用程序。现在还不清楚是否有更多的内容,并且没有滚动指示器(滚动视图已分页) 因此,为了给用户一个‘嘿,这里有东西……’,我想让滚动视图在启动时做一个微妙的向下反弹,然后向上反弹。我试过这个: - (void)viewDidLoad .... [NSTimer scheduledTimerWithTimeInterval:0.8 target:self selector:@selector(bounceScrollView) userInfo:nil
- (void)viewDidLoad
....
[NSTimer scheduledTimerWithTimeInterval:0.8 target:self selector:@selector(bounceScrollView) userInfo:nil repeats:NO];
}
- (void)bounceScrollView
{
[self.verticalScrollViews[0] scrollRectToVisible:CGRectMake(0, 600, 1, 1) animated:YES];
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(_unbounceScrollView) userInfo:nil repeats:NO];
}
- (void)_unbounceScrollView
{
[self.verticalScrollViews[0] scrollRectToVisible:CGRectZero animated:YES];
}
但是,此代码使视图在两个页面之间的中间位置“卡住”
有什么帮助吗?想法1:您需要关闭分页,设置反弹动画,然后重新打开分页 创意2:你的第二步来得太早了:
scheduledTimerWithTimeInterval:0.01
尝试更长的时间间隔!我将从0.4
开始
Idea 3:为什么不使用
flashScrollIndicators
,而不是反弹?这正是它的目的 我在使用NSTimer时遇到了内存问题。这就是为什么我在scrollView预览中使用了另一种解决方案
[UIView animateWithDuration:1.0
delay:0.00
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
_scrollView.contentOffset = CGPointMake(200,0);
}
completion:^(BOOL finished){
[UIView animateWithDuration:1.0
delay:0.00
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
_scrollView.contentOffset = CGPointMake(0,0);
}
completion:^(BOOL finished){
}
];
}
];
你能用完整的代码编辑一下你的问题吗?我也想实现这个动画。垂直滚动视图的声明在哪里?非常感谢。verticalScrollViews只是一个滚动视图数组-普通、通用、日常、
UIScrollViews
。我让它工作了,但它只是向下移动。我想把它垂直放置,但它似乎卡住了。@MasterRazer听起来像是你想要的-我不是这方面的专家。不!我的答案解决了,但我有个问题!我将您的代码粘贴到我的中,但_unbouncScrollView方法似乎不起作用!你知道我做错了什么吗?这是一个更干净的解决方案,没有混乱的方法和计时器