1.图片的获取
UIImage * image = [UIImage imageNamed:<#(NSString *)#>];
这种创建图片的方式是有缓存的。
创建无缓存的图片应采用下面这种方式:
UIImage * image = [UIImage imageWithContentsOfFile:<#(NSString *)#>];
imageWithContentsOfFile 方法要求后面的NSString填的是全路径名,获得全路径采用NSBundle的方法
NSBundle * bundle = [NSBundle mainBundle];
NSString * path = [bundle pathForResource:<#(NSString *)#> ofType:<#(NSString *)#>];
第一个NSString中写文件名,第二个NSString中写文件后缀。
2.NSBundle
1> 一个NSBundle代表一个文件夹,利用NSBundle能访问对应的文件夹
2> 利用mainBundle就可以访问软件资源包中的任何资源
3.UIImageView和UIButton
1> 使用场合
* UIImageView: 如果仅仅是显示图片,不需要监听图片的点击
* UIButton: 既要显示图片,又要监听图片的点击
2> 相同:能显示图片
3> 不同点
* UIButton能处理点击事件, UIImageView不能处理点击事件
* UIButton既能显示图片, 又能显示文字
* UIButton能同时显示两张图片
* UIButton继承自UIControl, 因此默认就能处理事件
* UIImageView继承自UIView, 因此默认就不能处理事件