Created
May 2, 2013 19:12
-
-
Save JaviSoto/5504598 to your computer and use it in GitHub Desktop.
iOS Debug display image function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @discussion takes the passed image parameter and displays a view controller modally that shwos the image | |
* You can call it from the debugger like this: | |
* expr JSDebugDisplayImage(image) | |
* @note you can dismiss the view controller simply by tapping on it | |
*/ | |
extern void JSDebugDisplayImage(UIImage *image); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface JSDebugDisplayImageViewController : UIViewController | |
- (id)initWithImage:(UIImage *)image; | |
@property (nonatomic, strong) UIImage *image; | |
@property (nonatomic, weak) UIImageView *imageView; | |
@end | |
@implementation JSDebugDisplayImageViewController | |
- (id)initWithImage:(UIImage *)image | |
{ | |
if ((self = [super init])) | |
{ | |
self.image = image; | |
} | |
return self; | |
} | |
- (void)loadView | |
{ | |
[super loadView]; | |
self.imageView = [[UIImageView alloc] initWithImage:self.image]; | |
self.imageView.frame = self.view.bounds; | |
self.imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | |
self.imageView.contentMode = UIViewContentModeScaleAspectFit; | |
[self.view addSubview:self.imageView]; | |
} | |
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event | |
{ | |
[self dismissViewControllerAnimated:YES completion:nil]; | |
} | |
@end | |
void JSDebugDisplayImage(UIImage *image) | |
{ | |
JSDebugDisplayImageViewController *imageVC = [[JSDebugDisplayImageViewController alloc] initWithImage:image]; | |
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:imageVC animated:YES completion:nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment