nsbundletheoslogoscydia-substrate

How to Display an image through a NSBundle


I am trying to display a image when my method is activated. I have all the code down and I dont get any errors but the image just wont show. Here is my Tweak.xm file.

#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>
#import <UIKit/_UITableViewUpdateSupport.h>
#import <UIKit/UI9PartImageView.h>
#import <UIKit/UIAlertSheetTextField.h>
#import <UIKit/UIAutocorrectImageView.h>
#import <UIKit/UIClippedImageView.h>
#import <UIKit/UICompositeImageView.h>
#import <UIKit/UIImageAndTextTableCell.h>
#import <UIKit/UIImageView2.h>
#import <UIKit/UIOnePartImageView.h>
#import <UIKit/UITabBarSwappableImageView.h>
#import <UIKit/UITableViewCell2.h>
#import <UIKit/UITableViewCellEditControl.h>
#import <UIKit/UIThreePartImageView.h>
#define kBundlePath @"/Library/MobileSubstrate/DynamicLibraries/image.bundle"

%hook UISaveToCameraRollActivity
-(void)performActivity {
%orig;
NSBundle *bundle = [[NSBundle alloc] initWithPath:kBundlePath];
NSString *imagePath = [bundle pathForResource:@"pic" ofType:@"png"];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake (100, 200, 100, 100)];
imageView.image = [UIImage imageWithContentsOfFile:imagePath];

}
%end

and here is my MakeFile

include theos/makefiles/common.mk

TWEAK_NAME = test
test_FILES = Tweak.xm
test_FRAMEWORKS = UIKit
include $(THEOS_MAKE_PATH)/tweak.mk
BUNDLE_NAME = image
image_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries
image_FRAMEWORKS = UIKit
include $(THEOS_MAKE_PATH)/bundle.mk

Thanks guys I really do appreciate all the help, and I know that i have a lot of headers but this project was many different things at one point. Please let me know just what is going on because like i said I dont even get any error codes. Thanks!


Solution

  • You're not actually adding the imageview to a superview: it's never making it into the render hierarchy and is therefore never displayed on the screen. My recommendation would be to find a particular view controller and stuff the view into its view, or to create your own toplevel UIWindow and display your image there.