Iphone 自动分页滚动视图
我有个问题。我想在滚动视图中向用户显示一些内容。我想从左到右快速自动滚动滚动视图。我尝试使用DDAutoscrollview(如果有人知道),但它对我不起作用。是否有人能为我提供一个水平自动滚动Uiscrollview的解决方案?我为scrollview设置了一个pagecontrol,因为它使用分页。任何代码片段都很好 我的代码(仅在滚动视图中): h m 我正在使用故事板和ARCIphone 自动分页滚动视图,iphone,objective-c,ios,uiscrollview,Iphone,Objective C,Ios,Uiscrollview,我有个问题。我想在滚动视图中向用户显示一些内容。我想从左到右快速自动滚动滚动视图。我尝试使用DDAutoscrollview(如果有人知道),但它对我不起作用。是否有人能为我提供一个水平自动滚动Uiscrollview的解决方案?我为scrollview设置了一个pagecontrol,因为它使用分页。任何代码片段都很好 我的代码(仅在滚动视图中): h m 我正在使用故事板和ARC 谢谢您正在寻找-(void)scrollRectToVisible:(CGRect)rect动画:(BOOL)动
谢谢您正在寻找
-(void)scrollRectToVisible:(CGRect)rect动画:(BOOL)动画
。它将允许您在contentSize中给它一个rect,并滚动到它
我不知道准确的速度有多快,但你试过这种方法吗
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
// In your case, e.g.:
[scroller setContentOffset:CGPointMake(640, 0) animated:YES]
您不需要为此使用任何额外的库。UIScrollView有一个
contentOffset
属性,您只需在该属性上将动画标志设置为“是”:
[myScrollView setContentOffset:CGPointMake(320, 0) animated:YES];
或者可以将其包装在UIView动画中:
[UIView animateWithDuration:1.5f animations:^{
[myScrollView setContentOffset:CGPointMake(320, 0) animated:NO];
}];
无论哪种方式,您都可能希望将scroll视图的contentSize设置为至少640宽,以便可以实际翻页。如果用户加载视图,我只希望scrollview页面向右
[myScrollView setContentOffset:CGPointMake(320, 0) animated:YES];
[UIView animateWithDuration:1.5f animations:^{
[myScrollView setContentOffset:CGPointMake(320, 0) animated:NO];
}];