Image可能不响应imageWithContentsofFil

Image可能不响应imageWithContentsofFil

本文介绍了UIImage可能不响应imageWithContentsofFile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使图像在每次调用我的方法时出现.

Hi guys I am trying to make a image appear whenever my method is called.

这是我的代码

#import <UIKit/UIKit.h>
#import <substrate.h>
#import <Foundation/Foundation.h>
#import <UIKit/UISaveToCameraRollActivity.h>
#import <UIKit/_UIImageViewExtendedStorage.h>
#import <UIKit/_UIOnePartImageView.h>
#import <UIKit/_UIPrefTableCellPiece.h>
#import <UIKit/_UIStretchableImage.h>
#import <UIKit/_UISwitchSlider.h>
#import <UIKit/_UITableViewCellDeleteConfirmationControl.h>
#import <UIKit/UIImage.h>

%hook UISaveToCameraRollActivity
-(void)performActivity {
%orig;
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake (100, 200, 100, 100)];
imageView.image = [UIImage imageWithContentsofFile:@"/Users/Cyrus/test/pic.png"];
}
%end

这是我的错误代码我不断收到错误,UIImage可能无法响应+ imageWithContentsofFile.有人可以帮我吗?

Here is my error codeI keep getting the error UIImage may not respond to +imageWithContentsofFile.Can somebody help me out please?

Tweak.xm:17: warning: ‘UIImage’ may not respond to ‘+imageWithContentsofFile:’
Tweak.xm:17: warning: (Messages without a matching method signature
Tweak.xm:17: warning: will be assumed to return ‘id’ and accept
Tweak.xm:17: warning: ‘...’ as arguments.)

谢谢大家,我真的很感谢所有帮助.

Thanks guys I really do appreciate all the help.

推荐答案

它是imageWithContents**Of**File,而不是imageWithContentsofFile.

此外,该图片将不会加载.当代码在设备上运行时,路径位于本地计算机上.您应该使用layout/目录.

Also, that image won't load. The path is on your local computer while your code is running on your device. You should use the layout/ directory.

这篇关于UIImage可能不响应imageWithContentsofFile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 22:57