[UIImage imageNamed:@"icon.png"]
用上面的方法加载图片有问题.
这种方法在application bundle的顶层文件夹寻找由供应的名字的图象 。 如果找到图片,装载到iPhone系统缓存图象。那意味图片是(理论上)放在内存里作为cache的。
如果图片多乐,就傻了.
图片cache极有可能不会响应 memory warnings and release its objects
使用图片的时候一定要小心的alloc和release
推荐使用下面的方法做处理:
NSString *path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"png"];
myImage = [UIImage imageWithContentsOfFile:path];
或[UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"a.png"]];
用上面的方法加载图片有问题.
这种方法在application bundle的顶层文件夹寻找由供应的名字的图象 。 如果找到图片,装载到iPhone系统缓存图象。那意味图片是(理论上)放在内存里作为cache的。
如果图片多乐,就傻了.
图片cache极有可能不会响应 memory warnings and release its objects
使用图片的时候一定要小心的alloc和release
推荐使用下面的方法做处理:
NSString *path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"png"];
myImage = [UIImage imageWithContentsOfFile:path];
或[UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"a.png"]];