iPhone 上实现页面循环滚动
2010-03-10 16:10:00 来源:WEB开发网{
UIView* pView = [ary objectAtIndex:i];
// 0x12345691 这个是我在增加 pView 到 scrollview 前给 pView 做的标记。用来区分 scrollview 内部的 view
if(pView.hidden == NO && 0x12345691 == pView.tag)
{
[aryOrderd addObject:pView];
// NSLog(@"初开始化数组 把pView=%d加入 %d ",pView, i);
// NSLog(@"pView.center.x=%f ",pView.center.x);
}
}
int aryOrdredSize = [aryOrderd count];
NSArray* aryTemp = [[NSArray alloc] initWithArray:aryOrderd];
//排序
for(i=0;i
{
UIView* pView = [aryTemp objectAtIndex:i];
CGRect rccc = pView.frame;
float centerX = CGRectGetMidX(rccc);
int pageIndex = ceil(centerX/perWidth);
if(pView.hidden == NO && 0x12345691 == pView.tag)
{
if( pageIndex <= 0 || pageIndex > aryOrdredSize )
{
// NSLog(@"error calucate of page index");
int a=0;a=1/a;
}
// NSLog(@"排序中 把pView=%d插入 %d 位置",pView, pageIndex-1);
[aryOrderd replaceObjectAtIndex:(pageIndex-1) withObject:pView];
}
}
[aryTemp release];
//排完后开始整体挪动位置
if(x < minStart)
{
NSLog(@"-----------------------need left round");
//头位置放到最后,其他位置左移
for (i=0; i
{
UIView* pView = [aryOrderd objectAtIndex:i];
if(i==(aryOrdredSize-1))
{
CGPoint centerPt = pView.center;
centerPt.x = perWidth/2;
pView.center = centerPt;
}
else
{
CGPoint centerPt = pView.center;
centerPt.x += perWidth;
更多精彩
赞助商链接