UIImage may not respond to imageWithContentsofFile

柔情痞子 提交于 2019-12-11 11:58:32

问题


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

Here is my code

#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

Here is my error code I 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.


回答1:


It's imageWithContents**Of**File, not imageWithContentsofFile.

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.



来源:https://stackoverflow.com/questions/15725416/uiimage-may-not-respond-to-imagewithcontentsoffile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!