我四处寻找答案,但我发现的答案说真实设备区分大小写,我查看了我的代码,找不到任何问题,
我有 2 个 View Controller ,spViewController
是我的根,我有 secondViewController
是不言自明的,两者都有一个 UIImageView
来显示相同的图像,它是在模拟器中使用 UIImagePickerController
从图库中挑选出来的,而真正的 iPhone 图像确实显示在 spViewController's
UIImageView
但在模拟器中的 secondViewController
上 UIImageView
显示图像但在真实 iPhone 上图像不显示
这个代码在我的 secondViewController.m
{NSString *docsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *filepathJPG = [docsPath stringByAppendingPathComponent:@"imagefile.jpg"];
UIImage *img = [UIImage imageWithContentsOfFile: filepathJPG];
if (img != nil) {
_imageView.image = img;
BOOL adjustToSmallSize = YES;
CGRect smallSize = (CGRect){0,0,100,100};
if (adjustToSmallSize) {
_imageView.bounds = smallSize;
}
}
我自己做了一些测试,我一直在玩文件名和大写字母和拼写,如果我更改图像无法在模拟器中加载的任何内容的拼写,如果我将其保留为
imagefile.jpg
那么它加载在模拟器中,但不是真正的手机,我玩过帽子,我的 iPhone 或模拟器上似乎没有任何变化
最佳答案
你确定imagefile.JPG
是大写 JPG,或者可以是 imagefile.jpg
?还要检查 filepathJPG
当您的 imageView
时,字符串在运行时保持不变。无法加载此图像文件。
关于ios - 模拟器在 UIImageView 中显示我的图像,但在我的真实 iPhone 上却没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23739670/