ipheone scrollview自动滑动

zhanglj6260 2011-10-25 07:48:34
如题,如何让scrollview能自动滑动,不用手触就可以自己循环滑动
...全文
291 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
程序员小迷 2012-01-12
  • 打赏
  • 举报
回复
设置定时器,不断改变scrollview的位置,ok
qq867814126 2011-11-14
  • 打赏
  • 举报
回复
repeats:NO 改成 repeats:YES
hjy_x 2011-11-12
  • 打赏
  • 举报
回复
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.25
target:self
selector:@selector(handleTimer:)
userInfo:nil
repeats:YES];
dshy1234 2011-11-07
  • 打赏
  • 举报
回复
repeats:NO ???
zzxxdd 2011-10-31
  • 打赏
  • 举报
回复
......





打log看下xPoint的值的变化规律
zhanglj6260 2011-10-31
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 zzxxdd 的回复:]
别在定时器里放循环啊~

假设 你的pNum = 2000

你该在定时器里写

if (xPoint > 2000)
xPoint = 0

xPoint += 320

[scrollView setContentOffset:CGPointMake(xPoint, 0) animated:YES];

然后定时器的时间间隔长一点
[/Quote]

用了这种方法了,第一页到第二页是自动过去了,但是第二页又秒过去了,我就不知道怎么回事了
zzxxdd 2011-10-28
  • 打赏
  • 举报
回复
别在定时器里放循环啊~

假设 你的pNum = 2000

你该在定时器里写

if (xPoint > 2000)
xPoint = 0

xPoint += 320

[scrollView setContentOffset:CGPointMake(xPoint, 0) animated:YES];

然后定时器的时间间隔长一点
zzxxdd 2011-10-27
  • 打赏
  • 举报
回复
。。。。

你在把代码贴上来看哈~应该不会吧。。。
zhanglj6260 2011-10-27
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 zzxxdd 的回复:]
CGPointMake(320, 0)

把坐标设置成变量,每次在促发定时器的时候为这个变量上加一个特定的值,如果超过了你设定的最大值就归0就可以了啊
[/Quote]
我改了,但是还是一页。。。加循环也一样的
zzxxdd 2011-10-27
  • 打赏
  • 举报
回复
CGPointMake(320, 0)

把坐标设置成变量,每次在促发定时器的时候为这个变量上加一个特定的值,如果超过了你设定的最大值就归0就可以了啊
zhanglj6260 2011-10-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zzxxdd 的回复:]

起个定时器 里边用setContentOffset
[/Quote]

我加了定时器了,但是他只是从自动滑动到2,之后就不在自动滑动了,需要我手触

NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.25
target:self
selector:@selector(handleTimer:)
userInfo:nil
repeats:NO];
- (void) handleTimer: (NSTimer *) timer
{

[scrollView setContentOffset:CGPointMake(320, 0) animated:YES];


}

zhanglj6260 2011-10-27
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 zzxxdd 的回复:]
。。。。

你在把代码贴上来看哈~应该不会吧。。。
[/Quote]
这个后来出来了,但是瞬间就都过去了,有没有办法让他慢点啊
zhanglj6260 2011-10-27
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 zzxxdd 的回复:]
。。。。

你在把代码贴上来看哈~应该不会吧。。。
[/Quote]

我加了个循环啊,还是第一页滚动
- (void) handleTimer: (NSTimer *) timer
{
for (unsigned j=320; j<pNum; j++) {
[scrollView setContentOffset:CGPointMake(j, 0) animated:YES];
}

}
zzxxdd 2011-10-26
  • 打赏
  • 举报
回复
起个定时器 里边用setContentOffset
  • 打赏
  • 举报
回复
你用手触的会 不会不用手触的么 触摸滑动只是调用了自动滑动

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧