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
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { | |
UIView * previewView = [[[[[[[[[[self.picker.view // UILayoutContainerView | |
subviews] objectAtIndex:0] // UINavigationTransitionView | |
subviews] objectAtIndex:0] // UIViewControllerWrapperView | |
subviews] objectAtIndex:0] // UIView | |
subviews] objectAtIndex:0] // PLCameraView | |
subviews] objectAtIndex:0]; // PLPreviewView | |
[previewView touchesBegan:touches withEvent:event]; | |
} |
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
-(UIView *)findView:(UIView *)view withName:(NSString *)name{ | |
Class cl = [view class]; | |
NSString *desc = [cl description]; | |
if ([desc compare:name] == NSOrderedSame) | |
return view; | |
for (int i = 0; i < [view.subviews count]; i++) | |
{ | |
UIView *subView = [view.subviews objectAtIndex:i]; |
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
+ (UIImage *)imageFromView:(UIView *)view | |
{ | |
UIGraphicsBeginImageContext(view.frame.size); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
[view layer] renderInContext:context]; | |
UIImage *image = UIGraphicsGetImageFromImageContext(); | |
UIGraphicsEndImageContext(); | |
return image; | |
} |
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
unsigned char *getBitmapFromImage(UIImage *image) | |
{ | |
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); | |
if (colorSpace == NULL) { | |
fprintf(stderr, "Error allocating color space\n"); | |
return NULL; | |
} |
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
BOOL isJailbreak() | |
{ | |
int res = access("/var/mobile/Library/AddressBook/AddressBook.sqlitedb", F_OK); | |
if (res != 0) | |
return NO; | |
return YES; | |
} |
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
//HTTP POST - http://itunes.apple.com/lookup?id={appid} | |
//Result(JSON): | |
{ | |
"resultCount":1, | |
"results": [ | |
{ | |
"kind":"software", |
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
#define LAST_LAUNCH_VERSION_KEY @"last_launch_version_of_application" | |
- (BOOL)isFirstLoad | |
{ | |
NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
NSString *lastLaunchVersion = [defaults objectForKey:LAST_LAUNCH_VERSION_KEY]; | |
if (!lastLaunchVersion || ![lastLaunchVersion isEqualToString:currentVersion]) { |
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
CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;}; | |
CGFloat RadiansToDegrees(CGFloat radians) {return radians * 180 / M_PI;}; |
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
#ifdef DEBUG | |
# define DLog(...) NSLog(__VA_ARGS__) | |
#else | |
# define DLog(...) /* */ | |
#endif | |
#define ALog(...) NSLog(__VA_ARGS__) |
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
void drawCorner(CGContextRef context, CGRect rect, float corner) | |
{ | |
CGContextSaveGState(context); | |
CGContextTranslateCTM(context, CGRectGetMinX(rect), CGRectGetMinY(rect)); | |
CGContextScaleCTM(context, corner, corner); | |
CGFloat fw = CGRectGetWidth(rect) / corner; | |
CGFloat fh = CGRectGetHeight(rect) / corner; | |
CGContextMoveToPoint(context, fw, fh/2); | |
CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1); |
OlderNewer