Wednesday, October 31, 2012

unsupported architecture armv7 - Xcode 4.5

Got this error when try to submit universal application

On Build Settings, The Architectures are:

$(ARCHS_STANDARD_32_BIT)
armv6

Its fixed when change the value of "Build Active Architecture Only"

Build Active Architecture Only = Yes

Wednesday, October 24, 2012

iOS - Getting thumbnail of PDF document

We can get the thumbnail of any page of pdf document. The following example is getting the thumbnail of first page

            NSURL* pdfFileUrl = [NSURL fileURLWithPath:filePath];
            CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfFileUrl);
           
            CGPDFPageRef page = CGPDFDocumentGetPage(pdf, 1);//for the first  page
            CGRect aRect = CGPDFPageGetBoxRect(page, kCGPDFCropBox);           
            UIGraphicsBeginImageContext(aRect.size);
            CGContextRef context = UIGraphicsGetCurrentContext();
           
            CGContextSaveGState(context);
            CGContextTranslateCTM(context, 0.0, aRect.size.height);
            CGContextScaleCTM(context, 1.0, -1.0);
            CGContextTranslateCTM(context, -(aRect.origin.x), -(aRect.origin.y));
           
            CGContextSetGrayFillColor(context, 1.0, 1.0);
            CGContextFillRect(context, aRect);
           
            CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, aRect, 0, false);
            CGContextConcatCTM(context, pdfTransform);
            CGContextDrawPDFPage(context, page);
           
            UIImage *thumbnail = UIGraphicsGetImageFromCurrentImageContext();           
            CGContextRestoreGState(context);
            UIGraphicsEndImageContext();
            CGPDFDocumentRelease(pdf);

iOS - get the thumbnail of a video

We can get the thumbnail of any time. The following example is at time 0

MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:filePath]];
moviePlayer.shouldAutoplay = NO;
UIImage *thumbnail = [moviePlayer thumbnailImageAtTime:0 timeOption:MPMovieTimeOptionNearestKeyFrame];
[moviePlayer stop];
[moviePlayer release];


Another way to get the frame - http://stackoverflow.com/a/4330647

Monday, October 22, 2012

-bash: svn: command not found - After Mountain Lion update

To install the command line tools
Xcode Menu, Go to preferences , In the Download tab, click to install Command line tools.