标签:count tom iOS NSBundle NSString 开发 Tom path UIImage
原文链接:http://www.cnblogs.com/caishugeng/p/3741304.html@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
标签:count,tom,iOS,NSBundle,NSString,开发,Tom,path,UIImage 来源: https://blog.csdn.net/weixin_30338743/article/details/98307243
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。