Search Results

Search found 10 results on 1 pages for 'carloe'.

Page 1/1 | 1 

  • iPhone: CGPDFPageRef & CGPDFPageRelease memory leak and cryptic error message

    - by carloe
    Could someone tell me why the code below outputs "missing or invalid MediaBox" in the console? The code works fine if I remove CGPDFPageRelease(page);, but then my app starts leaking like crazy. -(CGSize)dimensionOfPageAtIndex:(int)index { CGPDFPageRef page = CGPDFDocumentGetPage(pdf, index); CGRect tempRect = CGPDFPageGetBoxRect(page, kCGPDFBleedBox); CGSize tempSize = CGSizeMake(tempRect.size.width, tempRect.size.height); CGPDFPageRelease(page); return tempSize; } I also have this code in my app, and releasing the pageref here works just fine... -(UIImage *)pageAtIndex:(NSInteger)pageNumber withWidth:(CGFloat)width andHeight:(CGFloat)height { if((pageNumber>0) && (pageNumber<=pageCount)) { CGFloat scaleRatio; // multiplier by which the PDF Page will be scaled UIGraphicsBeginImageContext(CGSizeMake(width, height)); CGContextRef context = UIGraphicsGetCurrentContext(); CGPDFPageRef page = CGPDFDocumentGetPage(pdf, pageNumber); CGRect pageRect = CGPDFPageGetBoxRect(page, kCGPDFBleedBox); //Figure out the orientation of the PDF page and set the scaleRatio accordingly if(pageRect.size.width/pageRect.size.height < 1.0) { scaleRatio = height/pageRect.size.height; } else { scaleRatio = width/pageRect.size.width; } //Calculate the offset to center the image CGFloat xOffset = 0.0; CGFloat yOffset = height; if(pageRect.size.width*scaleRatio<width) { xOffset = (width/2)-(pageRect.size.width*scaleRatio/2); } else { yOffset = height-((height/2)-(pageRect.size.height*scaleRatio/2)); } CGContextTranslateCTM(context, xOffset, yOffset); CGContextScaleCTM(context, 1.0, -1.0); CGContextSaveGState(context); CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFBleedBox, CGRectMake(0, 0, pageRect.size.width, pageRect.size.height), 0, true); pdfTransform = CGAffineTransformScale(pdfTransform, scaleRatio, scaleRatio); CGContextConcatCTM(context, pdfTransform); CGContextDrawPDFPage(context, page); CGContextRestoreGState(context); UIImage *tempImage = UIGraphicsGetImageFromCurrentImageContext(); CGContextRelease(context); CGPDFPageRelease(page); return tempImage; } return NO; }

    Read the article

  • Convert NSString to CFURLRef

    - by carloe
    How can I convert a NSString that contains an absolute path to a file to a CFURLRef? I tried CFURLRef myFileUrl = CFURLCreateWithString(kCFAllocatorDefault, (CFStringRef)filePathString, NULL); and about half a dozend other ways.

    Read the article

  • iPad: CFBundleDocumentTypes & UIFileSharingEnabled issues

    - by carloe
    Has anyone gotten UIFileSharingEnabled or CFBundleDocumentTypes to work? I added UIFileSharingEnabled as true to my plist and used Apple's example from the link below for CFBundleDocumentTypes, but can't seem to get it to work. I don't see my app under file sharing in iTunes, and I do not get the option to open documents I registered in my app when I click on them in the mail.app http://developer.apple.com/iphone/library/documentation/General/Conceptual/iPadProgrammingGuide/CoreApplication/CoreApplication.html

    Read the article

  • iPhone: CoreGraphics and memory management

    - by carloe
    Can someone tell me what I am doing wrong here? I use this method to flip through pages in a PDF. But something in the code seems to not be released properly because every-time I pull a PDF page that contains an image my memory footprint increases. I am fairly new to CoreGraphics, and can't for the life of me figure out where this method would leak memory. -(UIImage *)pageAtIndex:(NSInteger)pageNumber withWidth:(CGFloat)width andHeight:(CGFloat)height { if((pageNumber>0) && (pageNumber<=pageCount)) { CGFloat scaleRatio; // multiplier by which the PDF Page will be scaled UIGraphicsBeginImageContext(CGSizeMake(width, height)); CGContextRef context = UIGraphicsGetCurrentContext(); CGPDFPageRef page = CGPDFDocumentGetPage(pdf, pageNumber); CGRect pageRect = CGPDFPageGetBoxRect(page, kCGPDFBleedBox); //Figure out the orientation of the PDF page and set the scaleRatio accordingly if(pageRect.size.width/pageRect.size.height < 1.0) { scaleRatio = height/pageRect.size.height; } else { scaleRatio = width/pageRect.size.width; } //Calculate the offset to center the image CGFloat xOffset = 0.0; CGFloat yOffset = height; if(pageRect.size.width*scaleRatio<width) { xOffset = (width/2)-(pageRect.size.width*scaleRatio/2); } else { yOffset = height-((height/2)-(pageRect.size.height*scaleRatio/2)); } CGContextTranslateCTM(context, xOffset, yOffset); CGContextScaleCTM(context, 1.0, -1.0); CGContextSaveGState(context); CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFBleedBox, CGRectMake(0, 0, pageRect.size.width, pageRect.size.height), 0, true); pdfTransform = CGAffineTransformScale(pdfTransform, scaleRatio, scaleRatio); CGContextConcatCTM(context, pdfTransform); CGContextDrawPDFPage(context, page); UIImage *tempImage = [UIGraphicsGetImageFromCurrentImageContext() retain]; CGContextRestoreGState(context); UIGraphicsEndPDFContext(); UIGraphicsEndImageContext(); return tempImage; } return nil; }

    Read the article

  • iPhone: Execute code after animation of UIDeviceOrientation change finishes

    - by carloe
    Not sure if I can explain this correctly, but I am trying to execute a method device orientation animation finishes. Right now I have [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];, but that triggers instantly. Is there a way to have it call didRotate after the view rotation animation is completed? Thanks!

    Read the article

  • iPhone: Activate UISlider and set its value to the location of the current touch programatically

    - by carloe
    Is it possible to set an UISlider as first responder and set its current value to the location of the current touch programatically? The way my app is set up I have a UIView container that takes up the whole screen. Inside the container I have another UIView offscreen at the bottom edge (I'll call this bottomBar). Inside the bottomBar there is a UISlider element. Right now, when the user swipes along the bottom edge of the screen the bottomBar the slider it contains slide up. What I am trying to achieve is to activate the UISlider, and set the position of the slider (the value) to the position of the users touch. Is this possible? Could someone please point me in the right direction?

    Read the article

  • CFBundleDocumentTypes & UIFileSharingEnabled issues

    - by carloe
    Has anyone gotten UIFileSharingEnabled or CFBundleDocumentTypes to work? I added UIFileSharingEnabled as true to my plist and used Apple's example from the link below for CFBundleDocumentTypes, but can't seem to get it to work. I don't see my app under file sharing in iTunes, and I do not get the option to open documents I registered in my app when I click on them in the mail.app http://developer.apple.com/iphone/library/documentation/General/Conceptual/iPadProgrammingGuide/CoreApplication/CoreApplication.html

    Read the article

  • NSString: EOL and rangeOfString issues

    - by carloe
    Could someone please tell me if I am missing something here... I am trying to parse individual JSON objects out of a data stream. The data stream is buffered in a regular NSString, and the individual JSON objects are delineated by a EOL marker. if([dataBuffer rangeOfString:@"\n"].location != NSNotFound) { NSString *tmp = [dataBuffer stringByReplacingOccurrencesOfString:@"\n" withString:@"NEWLINE"]; NSLog(@"%@", tmp); } The code above outputs "...}NEWLINE{..." as expected. But if I change the @"\n" in the if-statement above to @"}\n", I get nothing.

    Read the article

  • CALayer: callback when animation ends?

    - by carloe
    Hi All, I have been running into some issues with animating multiple CALayers at the same time, and was hoping someone could point me in the right direction. My app contains an array of CALayer. The position of each layer is set to (previousLayer.position.y + previousLayer.bounds.height), which basically lays them out similar to a table. I then have a method that, every-time it is called, adds a new layer to the stack and sets its Y position is set to 0. The Y positions of all other layers in the array are then offset by the height of the new layer (essentially pushing all old layers down). What I am having problems with is preventing the adding of new layers until the previous animation has completed. Is there a way to tell when an implicit animation has finished? Or alternatively, if I use CABasicAnimation and animationDidFinish, is there a way to tell which object finished animating when animationDidFinish is called?

    Read the article

1