ios - 模拟器在 UIImageView 中显示我的图像,但在我的真实 iPhone 上却没有

标签 ios uiimageview

我四处寻找答案,但我发现的答案说真实设备区分大小写,我查看了我的代码,找不到任何问题,

我有 2 个 View Controller ,spViewController 是我的根,我有 secondViewController 是不言自明的,两者都有一个 UIImageView 来显示相同​​的图像,它是在模拟器中使用 UIImagePickerController 从图库中挑选出来的,而真正的 iPhone 图像确实显示在 spViewController's UIImageView 但在模拟器中的 secondViewControllerUIImageView 显示图像但在真实 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/

相关文章:

ios - 返回一个 dispatch_async 获取的变量

iphone - 在项目中实现 UItabbarController + UInavigationBar

iphone - 向 UIImageView 添加圆角与预渲染 UIImage?

iphone - 如何将 UIView 图像 UIImageView 设置为背景?

ios - 确定 UIImageView 花费的时间 'drawing' 的方法?

Swift - 蒙版图像内边框

iphone - 如何在 iOS 编程中使用 pList

ios - 如何使用自动布局(约束)向 UIPageViewController 添加 subview ?

ios - 如何使用 CTCallCenter :setCallEventHandler: that occurred while the app was suspended? 获取调用事件

ios - UIImageView 并不总是为模板图像着色