21
A
回答
52
的文檔從某處加載圖片上的驅動器的使用:
UIImage * myImage = [UIImage imageWithContentsOfFile: @"../images/1.png"];
或者添加圖片到Xcode項目及用途:
UIImage * myImage = [UIImage imageNamed: @"1.png"];
之後, DD圖像的ImageView:
UIImageView * myImageView = [[UIImageView alloc] initWithImage: myImage];
10
只要圖像在您的資源文件夾中,您不需要提供任何路徑。
您可以使用它在imageView中顯示該圖像。
yourImageView.image = [UIImage imageNamed:@"something.png"];
+0
沒想到你需要把這個擴展與這種方法? – zonabi
1
UIImage *img = [UIImage imageWithContentsOfFile:(the file path)];
UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
0
你說的硬drive.Are你說你一直保持你的形象在iphone app.If你的包,那麼你可以作出這樣的圖像陣列圖像的意思...
NSMutableArray *imageArray;
imageArray=[[NSMutableArray alloc]initWithObjects:@"001.jpg",@"002.jpg",@"003.jpg",@"004.jpg",nil];
然後可以通過這個數組訪問你的圖像;
或者,如果你只是想表明從包一個單一的形象,你可以做這樣
UIImageView *creditCardImageView=[[UIImageView alloc]initWithFrame:CGRectMake(10, 16, 302, 77)];
creditCardImageView.image=[UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"CreditCard_2RowTable" ofType:@"png"]];
[self.view addSubview:creditCardImageView];
這將幫助你。
相關問題
- 1. UIImageView顯示UIImageView圖像UIImageView
- 2. 保存在UIImageView中顯示的圖像
- 3. 在iPhone的UIImageView中顯示圖像
- 4. 解析圖像並在uiimageview中顯示
- 5. 在UIImageView中顯示完整圖像
- 6. 在simplekml中顯示本地圖像
- 7. 在JTextPane中顯示本地圖像(BufferedImage?)
- 8. 顯示圖像從網站URL(json)本地顯示在本地
- 9. 爲什麼圖像不顯示在UIImageView
- 10. UIImageView在模擬器上顯示圖像,但在iPhone上未顯示圖像
- 11. 如何通過SQLite讀取並在UIImageView上顯示本地圖像
- 12. 與UIImageView性能不佳(本地圖像)
- 13. 在地圖註釋中顯示圖像
- 14. 斯威夫特顯示圖像的UIImageView
- 15. UIImageView不顯示來自UIImagePickerController的圖像
- 16. UIImageView不顯示從UITableViewController設置圖像
- 17. 的iOS的UIImageView不顯示圖像
- 18. XCode UIIMAGEVIEW從ftp顯示圖像
- 19. 從圖像URL加載圖像以顯示UIImageview中的動畫
- 20. 在界面生成器/ iPhone中的UIImageView中未顯示圖像
- 21. 從UIImagePickerController中選擇的圖像沒有顯示在UIImageView中
- 22. 不顯示本地CSS背景圖像
- 23. 使用Three20顯示本地圖像
- 24. 無法顯示本地圖像
- 25. 從safari本地磁盤顯示圖像
- 26. 圖片在UIImageView中顯示模糊
- 27. 我可以在iOS10的UIImageView中顯示GIF圖像嗎?
- 28. 在uiimageview中顯示來自url的圖像
- 29. UIImageView在UICollectionViewCell子類中顯示圖像越界
- 30. UIImageView未在自定義UITableViewCell中顯示圖像
既然你想打包你的應用程序,你應該使用這裏的最後兩行代碼,而不是最上面的一行。您還應該將該映像從硬盤驅動器拖到項目中的文件夾中,例如Resources文件夾。 – tazboy