1016-07-6、7適配問題,1016-07-67適配

來源:互聯網
上載者:User

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"];是載入圖片的全路徑。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.