1016-07-6、7適配問題,1016-07-67適配
圖片展開
___________________________________________________
___________________________________________________
1. 如果圖片比較大得話,不要用 [UIImage imageNamed:@"big.png"]; 去載入.
- (void)viewDidLoad
{
[super viewDidLoad];
UIImageView *imageView = [[UIImageView alloc] init];
imageView.image = [UIImage imageNamed:@"avatar_vip"];
// NSString *file = [[NSBundle mainBundle] pathForResource:@"avatar_vip@2x" ofType:@"png"];
// imageView.image = [UIImage imageWithContentsOfFile:file];
imageView.frame = CGRectMake(10, 50, 34, 34);
[self.view addSubview:imageView];
// 這個方法載入的圖片不會有緩衝,適合用來載入大圖片、一次性的圖片(使用頻率比較低)
// [UIImage imageWithContentsOfFile:<#(NSString *)#>];
// 這個方法載入的圖片會有緩衝,適合用來載入小圖片、使用頻率比較高的圖片
// [UIImage imageNamed:@"searchbar_textfield_background"];
// 建議:1.小圖片可以放在Images.xcassets中;2.大圖片建議放在Supporting Files中
}
___________________ 這個是NSBunld mainBunld 路徑,不是沙箱路徑 ________________________________
________________圖1 _______________________________________________________________圖2 ___________________
___________圖3 ________
圖一圖二圖三加起來是沙箱路徑,緩衝的圖片都存在 “6/7適配問題” 這個檔案夾這級目錄下面。[[NSBundle mainBundle] pathForResource:@"avatar_vip@2x" ofType:@"png"]; 在這一級目錄下找圖片資源。
1. 所有圖片都會壓縮在 Assets.car 裡面。
2. 圖片不管是放在 [NSBundle mainBundle] 裡面,還是壓縮在 Assets.car 裡面,[UIImage imageNamed:@"avatar_vip"];都是好使的。
3. 在iOS6中,圖片放在 Assets.car 裡面,[[NSBundle mainBundle] pathForResource:@"avatar_vip@2x" ofType:@"png"];是找不到的。iOS7是可以找到的。放在 Images.xcassets 裡面的圖片是有緩衝的。
4. 不管是適配幾,只要將圖片放在 Supporting Files 下面,圖片就會出現在 mainBundle 路徑裡面。所以只要放在這個目錄下,通過任何方法都能載入。
5. 放在Assets.car 裡面的圖片是不能通過 imageWithContentsOfFile 來載入的。
以上待整理。
6. Supporting Files 只能放圖片,不能看圖片的特性;放 Images.xcassets 下面的圖片卻可以。
7. [[NSBundle mainBundle] pathForResource:@"avatar_vip@2x" ofType:@"png"];是載入圖片的全路徑。