0
我正在编程一个在不同视图中有几个UIImage动画的应用程序。现在我使用这行代码来加载所有图像:轻松加载动画
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"10001.png" ofType:nil]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"10002.png" ofType:nil]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"10003.png" ofType:nil]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"10004.png" ofType:nil]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"10005.png" ofType:nil]],
并加载所有这100个图像。
然后,在第二视图中,我加载它喜欢这些:
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"20001.png" ofType:nil]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"20002.png" ofType:nil]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"20003.png" ofType:nil]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"20004.png" ofType:nil]],
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"20005.png" ofType:nil]],
和再次加载100个图像。
有没有什么方法可以加载所有的图像,但只放一次图像的名称?我想要的是,例如,把前两个数字(10),然后自动加载其余的图像。在Xcode中可能吗?谢谢!
stringWithFormat:%@“%u.png” - > stringWithFormat:@“%u.png”no? :) – bs7
好thnaks,我会试试看。 – joan2404
@ bs7哎呀,你是对的!修复。 – JustSid