uiimagetheoslogos

UIImage may not respond to imageWithContentsofFile


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.


Solution

  • 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.