WEB开发网
开发学院手机开发iPhone 开发 iPhone 上实现页面循环滚动 阅读

iPhone 上实现页面循环滚动

 2010-03-10 16:10:00 来源:WEB开发网   
核心提示:- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{//; // called when scroll view grinds to a halt[self setScrollPosition];}- (void)scrollViewDidEn

- (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 minStart - perWidth) && !(x>maxStart && x < maxStart + perWidth))

{

return;

}

if(totalWidth <= perWidth*2)

{

return;//只有两个元素的情况

}

if(x < minStart || x >maxStart)

{

NSLog(@"self.contentOffset.x=%f",self.contentOffset.x);

// 进入第一步,调整 contextOff 的位置

int nx = 0;

上一页  1 2 3 4 5 6 7 8  下一页

Tags:iPhone 实现 页面

编辑录入:coldstar [复制链接] [打 印]
赞助商链接