1

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 Answers1

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.

David Murray
  • 541
  • 5
  • 19
  • Thank you so so much that helped a lot! Also can you explain what you mean by the layout/ format. I havent heard of it before? thanks again. – Cyrus Bastankhah Mar 31 '13 at 01:57
  • An example is worth a thousand words. https://github.com/rpetrich/BrowserChooser Let me know if you need more help! – David Murray Mar 31 '13 at 02:01
  • thanks man this is awesome you are the first person to ever help me on this website thanks a lot. – Cyrus Bastankhah Mar 31 '13 at 02:09
  • So i have been looking at this and I am not quite understanding just what I would need to do. I think that I need to make a plist is that correct? or would I need to write something in my tweak.xm file. could you please show me just what I need to do. I am new to coding and im trying to get a swing on things thanks! – Cyrus Bastankhah Mar 31 '13 at 02:25
  • Just make a layout/ directory and inside that directory, include the normal full path to your files on your iphone. Example, if you want to have a file stored in /Library/YOUR_TWEAK_NAME/Image.png, you'd do: layout/Library/YOUR_TWEAK_NAME/Image.png. Your image will then be copied to the device. – David Murray Apr 01 '13 at 21:14