ios跑马灯
来源:互联网 发布:数据库迁移 编辑:程序博客网 时间:2024/04/29 15:57
之前项目做一个类似跑马灯的效果
因为项目需求每次回到跑马灯页面都要从第一个开始动画
所以刚开始就用了UIView的Animations动画,在动画结束后调用一个方法来改变数据然后继续Animations,在没离开这个页面的时候都是正常的,可是没想到离开这个页面后 这个动画的时间好像就不起作用了似的,一直在互相掉没有延迟时间了!一直没找到问题的所在;
之后在开发过程中突然想到用系统的延迟方法:
[self performSelector:@selector(startTimer) withObject:nil afterDelay:kStartTime];
替换Animations的
+ (void)setAnimationDidStopSelector:(SEL)selector;
方法来做动画结束的功能
代码例子:
-(void)startTimer{
textIndex++;
[textLabel setViewX:300];
if (textIndex >= [textArray count])
textIndex = 0;
textLabel.text =[textArray objectAtIndex:textIndex];
if (isAnimation) {
[self textRunner];
}
}
-(void)textRunner{
// -------滚动
[UIView beginAnimations:@"testAnimation" context:NULL];
[UIView setAnimationDuration:kStartTime];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDelegate:self];
[UIView setAnimationRepeatAutoreverses:NO]; //不重复播放
//使用延迟方法替代动画结束调用方法功能
[self performSelector:@selector(startTimer) withObject:nil afterDelay:kStartTime];
[textLabel setViewX:-400];
[UIView commitAnimations];
}
如果有需求的话可以调用
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(startTimer) object:nil];
来停止动画的互相调用
如果有朋友知道我的问题出在哪里指点一下小弟
为什么离开页面后他的延迟时间就不好使了!!!!!!!!!!!!!!!!!!!!
- IOS 跑马灯效果
- ios跑马灯
- iOS 跑马灯效果
- iOS 跑马灯效果
- ios 自制跑马灯
- IOS跑马灯效果
- iOS实现跑马灯效果
- iOS实现跑马灯效果
- iOS巅峰之跑马灯
- iOS开发之跑马灯
- iOS开发之跑马灯
- iOS 跑马灯效果展示
- iOS 跑马灯之 TXScrollLabelView
- iOS跑马灯效果的源代码
- IOS的跑马灯之HelloWorld
- ios—跑马灯.开始暂停
- iOS开发 - 广播(跑马灯)的实现
- iOS 实现UILabel的跑马灯效果
- hadoop(1.1.2) eclipse plugin编译
- 第三次上机实验报告1
- mysql Can't create/write to file 'C:\WINDOWS\...
- Kinect SDK 1.7新特性
- Hadoop源代码分析(一)源码结构
- ios跑马灯
- 经验分享:CSS浮动(float,clear)通俗讲解
- 网络编程(待)
- 外部表(三)--解读通过sql*loader生成的创建外部表的日志
- 用过的库
- 已有git库上传到服务器的做法
- 递归算法简单总结
- QT记事本
- Adobe Flash Stage3D ---- Molehill 相关