iOS开发之Tom猫
@interfaceViewController ()
@end
//定义一个全局的可变数据字典
NSMutableDictionary *dictionary;
@implementation ViewController
- (void)viewDidLoad
{
[superviewDidLoad];
//在viewDidLoad加载资源包,避免每次点击时都需要加载资源包,
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle pathForResource:@"tom" ofType:@"plist"];
dictionary = [NSMutableDictionarydictionaryWithContentsOfFile:path];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)setCount:(int)count setName:(NSString *)Name
{
// 定义了一个可变数组,用来存放照片
NSMutableArray *images = [NSMutableArrayarray];
for (int i=0; i<count; i++) {
NSString *name = [NSString stringWithFormat:@"%@_%02d.jpg",Name,i];
// UIImage *img = [UIImage imageNamed:name];
/*通过调用[[NSBundle mainBundle]pathForResource: ofType: ]
和[[UIImage alloc]initWithContentsOfFile:path],这两句,可以避免咱用缓存不释放
*/
NSString *path = [[NSBundle mainBundle]pathForResource:name ofType:nil];
UIImage *imagesname = [[UIImage alloc]initWithContentsOfFile:path];
[images addObject:imagesname];
}
_tom.animationImages = images;
_tom.animationRepeatCount = 1;
_tom.animationDuration = count*0.1;
[_tomstartAnimating];
}
- (IBAction)btnClik:(UIButton *)sender {
if ([_tomisAnimating])
return;
NSString *title = [sender titleForState:UIControlStateNormal];
int count = [dictionary[title]intValue];
[self setCount:count setName:title];
}
@end
转载于:https://www.cnblogs.com/caishugeng/p/3741304.html
- IOS开发基础—通过Tom猫实例学习uiimageview的基本使用
- Ios开发-第一天-Tom猫
- IOS初体验-Tom猫的开发
- iOS开发 - 第01篇 - UI基础 - 02 - 图片浏览&TOM猫
- iOS开发-Tom猫
- iOS开发之Tom猫
- 【iOS开发-45】Tom猫案例:动画、imageNamed与imageWithContentOfFile对内存影响、图片文件夹放哪儿以及文档注释
- IOS开发实战-----Tom猫
- iOS开发脚踏实地学习day02-图片查看器和TOM猫
- iOS 开发之 Web Service 调用
- ios开发:多个Section的TableView
- IOS开发中多线程的使用
- iOS开发中@property的属性介绍
- IOS开发—本地推送
- iOS开发系列--音频播放、录音、视频播放、拍照、视频录制
- iOS开发CoreGraphics核心图形框架之五——Patterns模型的应用
- iOS开发中UITabBarController的使用示例
- iOS开发那些事-iOS网络编程同步GET方法请求编程
- [ios2] ios开发之MPNowPlayingInfoCenter 锁屏显示正在播放的音乐
- IOS开发语言Swift入门连载---字符串和字符