Skip to content

Instantly share code, notes, and snippets.

@taberh
taberh / gist:3161590
Created July 23, 2012 01:19
check jailbreak device for iPhone
BOOL isJailbreak()
{
int res = access("/var/mobile/Library/AddressBook/AddressBook.sqlitedb", F_OK);
if (res != 0)
return NO;
return YES;
}
@taberh
taberh / gist:3031954
Created July 2, 2012 08:34
get bitmap from image
unsigned char *getBitmapFromImage(UIImage *image)
{
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
if (colorSpace == NULL) {
fprintf(stderr, "Error allocating color space\n");
return NULL;
}
@taberh
taberh / imageFromView
Created July 2, 2012 03:25
get UIImage object in the UIView
+ (UIImage *)imageFromView:(UIView *)view
{
UIGraphicsBeginImageContext(view.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[view layer] renderInContext:context];
UIImage *image = UIGraphicsGetImageFromImageContext();
UIGraphicsEndImageContext();
return image;
}
@taberh
taberh / fineViewWithName
Created April 15, 2012 03:08
find view with view name
-(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];
@taberh
taberh / gist:2389644
Created April 15, 2012 03:04
iphone uiimagepickercontroller subviews structure
-(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];
}