iPhone 上实现页面循环滚动
2010-03-10 16:10:00 来源:WEB开发网- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{//; // called when scroll view grinds to a halt
[self setScrollPosition];
}
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{//; // called when setContentOffset/scrollRectVisible:animated: finishes. not called if not animating
[self setScrollPosition];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{//; // called when scroll view grinds to a halt
[self setScrollPosition];
}
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{//; // called when setContentOffset/scrollRectVisible:animated: finishes. not called if not animating
[self setScrollPosition];
}
控制UIView偏移与 UIScrollView offset 位置的实现:
view plaincopy to clipboardprint?
//调整位置
- (void)setScrollPosition
{
if([self isPagingEnabled] == NO)
{
return;
}
if(self.dragging != NO && self.decelerating != NO)
{
return;
}
int x = self.contentOffset.x;
int totalWidth = self.contentSize.width;
int perWidth = self.frame.size.width;
int minStart = 4;
int maxStart = totalWidth - perWidth - 4 ;
if(!(x
{
return;
}
if(totalWidth <= perWidth*2)
{
return;//只有两个元素的情况
}
if(x < minStart || x >maxStart)
{
NSLog(@"self.contentOffset.x=%f",self.contentOffset.x);
// 进入第一步,调整 contextOff 的位置
int nx = 0;
更多精彩
赞助商链接