iPhone 上从缓存加载图像的问题

发布于 2024-08-15 20:30:28 字数 1707 浏览 2 评论 0原文

这是我的代码

UIImage * result = [[UIImage alloc] imageWithContentsOfFile:filePath];

,这是我的错误日志

> 2009-12-22 17:00:44.137
> DrillDownApp[2061:207] touchesBegan
> from root 2009-12-22 17:00:44.138
> DrillDownApp[2061:207] touchesBegan
> from root at X = 52.000 and Y = 87.000
> at INDEX = 0 2009-12-22 17:00:44.139
> DrillDownApp[2061:207] index = 0
> 2009-12-22 17:00:44.140
> DrillDownApp[2061:207] Begin Load
> Image 2009-12-22 17:00:44.141
> DrillDownApp[2061:207] Load Image
> complete 2009-12-22 17:00:44.142
> DrillDownApp[2061:207] get index = 0
> 2009-12-22 17:00:44.143
> DrillDownApp[2061:207]
> /Users/ragopor/Library/Application
> Support/iPhone
> Simulator/User/Applications/47C3AA6B-4C93-4A17-BF3C-D212D11951F2/Documents/URLCache/P4010143.jpg
> 2009-12-22 17:00:44.144
> DrillDownApp[2061:207] *** -[UIImage
> imageWithContentsOfFile:]:
> unrecognized selector sent to instance
> 0x3d180b0 2009-12-22 17:00:44.144
> DrillDownApp[2061:207] *** Terminating
> app due to uncaught exception
> 'NSInvalidArgumentException', reason:
> '*** -[UIImage
> imageWithContentsOfFile:]:
> unrecognized selector sent to instance
> 0x3d180b0' 2009-12-22 17:00:44.145
> DrillDownApp[2061:207] Stack: (
>     29721691,
>     2449544457,
>     30103611,
>     29673078,
>     29525698,
>     13756,
>     20415,
>     20979,
>     25843,
>     18694,
>     3160730,
>     3143896,
>     397754,
>     29506240,
>     29502536,
>     37812109,
>     37812306,
>     2887683,
>     11024,
>     10878 )

Here my code

UIImage * result = [[UIImage alloc] imageWithContentsOfFile:filePath];

here my error log

> 2009-12-22 17:00:44.137
> DrillDownApp[2061:207] touchesBegan
> from root 2009-12-22 17:00:44.138
> DrillDownApp[2061:207] touchesBegan
> from root at X = 52.000 and Y = 87.000
> at INDEX = 0 2009-12-22 17:00:44.139
> DrillDownApp[2061:207] index = 0
> 2009-12-22 17:00:44.140
> DrillDownApp[2061:207] Begin Load
> Image 2009-12-22 17:00:44.141
> DrillDownApp[2061:207] Load Image
> complete 2009-12-22 17:00:44.142
> DrillDownApp[2061:207] get index = 0
> 2009-12-22 17:00:44.143
> DrillDownApp[2061:207]
> /Users/ragopor/Library/Application
> Support/iPhone
> Simulator/User/Applications/47C3AA6B-4C93-4A17-BF3C-D212D11951F2/Documents/URLCache/P4010143.jpg
> 2009-12-22 17:00:44.144
> DrillDownApp[2061:207] *** -[UIImage
> imageWithContentsOfFile:]:
> unrecognized selector sent to instance
> 0x3d180b0 2009-12-22 17:00:44.144
> DrillDownApp[2061:207] *** Terminating
> app due to uncaught exception
> 'NSInvalidArgumentException', reason:
> '*** -[UIImage
> imageWithContentsOfFile:]:
> unrecognized selector sent to instance
> 0x3d180b0' 2009-12-22 17:00:44.145
> DrillDownApp[2061:207] Stack: (
>     29721691,
>     2449544457,
>     30103611,
>     29673078,
>     29525698,
>     13756,
>     20415,
>     20979,
>     25843,
>     18694,
>     3160730,
>     3143896,
>     397754,
>     29506240,
>     29502536,
>     37812109,
>     37812306,
>     2887683,
>     11024,
>     10878 )

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你是暖光i 2024-08-22 20:30:28

imageWithContentsOfFile 是一个类方法。您应该使用

[UIImage imageWithContentsOfFile:filePath];

[[UIImage alloc] initWithContentsOfFile:filePath];

imageWithContentsOfFile is a class method. You should use either

[UIImage imageWithContentsOfFile:filePath];

or

[[UIImage alloc] initWithContentsOfFile:filePath];
岁月如刀 2024-08-22 20:30:28

imageWithContentsOfFile 是一个返回 UIImage 的静态函数。无需分配图像。

UIImage * result = [UIImage imageWithContentsOfFile:filePath];

imageWithContentsOfFile is a static function that returns a UIImage. No need to alloc an image.

UIImage * result = [UIImage imageWithContentsOfFile:filePath];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文