This file contains 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
/** | |
* Upload an image to twitter to get media_id for is | |
* | |
* @param img The image (UIImage or NSData) to be uploaded | |
* @param completion | |
*/ | |
- (void)sendTweetWithImage:(id)img withCompletion:(void(^)(NSNumber *mediaID, NSError *error))completion { | |
NSURL *requestURL = [[NSURL alloc] initWithString:@"https://upload.twitter.com/1.1/media/upload.json"]; |
This file contains 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
//Create an image about the screen of the iOS device | |
+ (UIImage *) screenshot{ | |
UIWindow *mainWindow = [[[UIApplication sharedApplication] windows] firstObject]; | |
if(UIGraphicsBeginImageContextWithOptions != NULL) | |
{ | |
UIGraphicsBeginImageContextWithOptions(mainWindow.frame.size, NO, 0.0f); | |
} else { | |
UIGraphicsBeginImageContext(mainWindow.frame.size); |
This file contains 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
//based on the solution of iamamused : https://gist.github.com/iamamused/1955318 | |
@implementation UIImage (ImageFromPDF) | |
+ (UIImage *)imageLoadedFromPDF:(NSString *)filePath fitSize:(CGSize)fitSize shouldCacheAsAFile:(BOOL)storeInFile{ | |
// Determine if the device is retina. | |
BOOL isRetina = [UIScreen instancesRespondToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.0; | |
// Create a file manager so we can check if the image exists and store the image. | |
NSFileManager *fileManger = [NSFileManager defaultManager]; |
NewerOlder