ipheone scrollview自动滑动
如题,如何让scrollview能自动滑动,不用手触就可以自己循环滑动--------------------编程问答-------------------- 你用手触的会 不会不用手触的么 触摸滑动只是调用了自动滑动 --------------------编程问答-------------------- 起个定时器 里边用setContentOffset --------------------编程问答--------------------
我加了定时器了,但是他只是从自动滑动到2,之后就不在自动滑动了,需要我手触
--------------------编程问答-------------------- CGPointMake(320, 0)
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];
}
把坐标设置成变量,每次在促发定时器的时候为这个变量上加一个特定的值,如果超过了你设定的最大值就归0就可以了啊
--------------------编程问答--------------------
我改了,但是还是一页。。。加循环也一样的 --------------------编程问答-------------------- 。。。。
你在把代码贴上来看哈~应该不会吧。。。 --------------------编程问答--------------------
我加了个循环啊,还是第一页滚动
- (void) handleTimer: (NSTimer *) timer--------------------编程问答--------------------
{
for (unsigned j=320; j<pNum; j++) {
[scrollView setContentOffset:CGPointMake(j, 0) animated:YES];
}
}
这个后来出来了,但是瞬间就都过去了,有没有办法让他慢点啊 --------------------编程问答-------------------- 别在定时器里放循环啊~
假设 你的pNum = 2000
你该在定时器里写
if (xPoint > 2000)
xPoint = 0
xPoint += 320
[scrollView setContentOffset:CGPointMake(xPoint, 0) animated:YES];
然后定时器的时间间隔长一点
--------------------编程问答--------------------
用了这种方法了,第一页到第二页是自动过去了,但是第二页又秒过去了,我就不知道怎么回事了 --------------------编程问答-------------------- ......
打log看下xPoint的值的变化规律 --------------------编程问答-------------------- --------------------编程问答-------------------- repeats:NO ??? --------------------编程问答-------------------- NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.25
target:self
selector:@selector(handleTimer:)
userInfo:nil
repeats:YES]; --------------------编程问答-------------------- repeats:NO 改成 repeats:YES --------------------编程问答-------------------- 设置定时器,不断改变scrollview的位置,ok
补充:移动开发 , iPhone