iphone Programming Glossary: context
How to make a UITextField move up when keyboard is present http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present the keyboard is shown dismissed void setViewMovedUp BOOL movedUp UIView beginAnimations nil context NULL UIView setAnimationDuration 0.3 if you want to slide up the view CGRect rect self.view.frame if..
Add UIPickerView & a Button in Action sheet - How? http://stackoverflow.com/questions/1262574/add-uipickerview-a-button-in-action-sheet-how against trying to customize the contents of an ActionSheet as it can lead to serious invalid context errors in iOS 7. I just spent a few hours working through this problem and ultimately decided to take..
How to Rotate a UIImage 90 degrees? http://stackoverflow.com/questions/1315251/how-to-rotate-a-uiimage-90-degrees UIImage src UIImageOrientation orientation UIGraphicsBeginImageContext src.size CGContextRef context UIGraphicsGetCurrentContext if orientation UIImageOrientationRight CGContextRotateCTM context radians.. context UIGraphicsGetCurrentContext if orientation UIImageOrientationRight CGContextRotateCTM context radians 90 else if orientation UIImageOrientationLeft CGContextRotateCTM context radians 90 else if.. context radians 90 else if orientation UIImageOrientationLeft CGContextRotateCTM context radians 90 else if orientation UIImageOrientationDown NOTHING else if orientation UIImageOrientationUp..
Cropping a UIImage http://stackoverflow.com/questions/158914/cropping-a-uiimage wondering if either is on base. Theory 1 I achieve the cropping by drawing into an offscreen image context of my target size. Since I want the center portion of the image I set the CGRect argument passed to.. the CGRect argument passed to drawInRect to something that's larger than the bounds of my image context. I was hoping this was Kosher but am I instead attempting to draw over other memory that I shouldn't..
How do I export UIImage array as a movie? http://stackoverflow.com/questions/3741323/how-do-i-export-uiimage-array-as-a-movie pxdata NULL CGColorSpaceRef rgbColorSpace CGColorSpaceCreateDeviceRGB CGContextRef context CGBitmapContextCreate pxdata frameSize.width frameSize.height 8 4 frameSize.width rgbColorSpace kCGImageAlphaNoneSkipFirst.. frameSize.height 8 4 frameSize.width rgbColorSpace kCGImageAlphaNoneSkipFirst NSParameterAssert context CGContextConcatCTM context frameTransform CGContextDrawImage context CGRectMake 0 0 CGImageGetWidth.. rgbColorSpace kCGImageAlphaNoneSkipFirst NSParameterAssert context CGContextConcatCTM context frameTransform CGContextDrawImage context CGRectMake 0 0 CGImageGetWidth image CGImageGetHeight image..
Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints? http://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints scale as well as a Layer approach. The CPU and memory hit on generating the UIImages from a PDFcontext limits prevents using it to create a real time render of new zoom levels. CATiledLayer Method Theres.. needless NSOperations When you can especially if they will be using memory beware of leaving contexts open though Recycle page objects by doing pointer swaps or destroy unused views Close any open Contexts.. it using the appropriate CTM. The code in void drawLayer CALayer layer inContext CGContextRef context is like CGAffineTransform currentCTM CGContextGetCTM context if currentCTM.a 1.0 baseImage Calculate..
iOS UIImagePickerController result image orientation after upload http://stackoverflow.com/questions/5427656/ios-uiimagepickercontroller-result-image-orientation-after-upload case UIImageOrientationRight break Now we draw the underlying CGImage into a new context applying the transform calculated above. CGContextRef ctx CGBitmapContextCreate NULL self.size.width.. self.size.height self.CGImage break And now we just create a new UIImage from the drawing context CGImageRef cgimg CGBitmapContextCreateImage ctx UIImage img UIImage imageWithCGImage cgimg CGContextRelease..
How to make a UITextField move up when keyboard is present http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present self setViewMovedUp YES method to move the view up down whenever the keyboard is shown dismissed void setViewMovedUp BOOL movedUp UIView beginAnimations nil context NULL UIView setAnimationDuration 0.3 if you want to slide up the view CGRect rect self.view.frame if movedUp 1. move the view's origin up so that the text field..
Add UIPickerView & a Button in Action sheet - How? http://stackoverflow.com/questions/1262574/add-uipickerview-a-button-in-action-sheet-how subclassed nor should you add views to its hierarchy I recommend against trying to customize the contents of an ActionSheet as it can lead to serious invalid context errors in iOS 7. I just spent a few hours working through this problem and ultimately decided to take a different approach. I replaced the call to show the action..
How to Rotate a UIImage 90 degrees? http://stackoverflow.com/questions/1315251/how-to-rotate-a-uiimage-90-degrees radians double degrees return degrees M_PI 180 UIImage rotate UIImage src UIImageOrientation orientation UIGraphicsBeginImageContext src.size CGContextRef context UIGraphicsGetCurrentContext if orientation UIImageOrientationRight CGContextRotateCTM context radians 90 else if orientation UIImageOrientationLeft CGContextRotateCTM.. orientation UIGraphicsBeginImageContext src.size CGContextRef context UIGraphicsGetCurrentContext if orientation UIImageOrientationRight CGContextRotateCTM context radians 90 else if orientation UIImageOrientationLeft CGContextRotateCTM context radians 90 else if orientation UIImageOrientationDown NOTHING else if orientation.. if orientation UIImageOrientationRight CGContextRotateCTM context radians 90 else if orientation UIImageOrientationLeft CGContextRotateCTM context radians 90 else if orientation UIImageOrientationDown NOTHING else if orientation UIImageOrientationUp CGContextRotateCTM context radians 90 src drawAtPoint CGPointMake..
Cropping a UIImage http://stackoverflow.com/questions/158914/cropping-a-uiimage I'm a bit stumped. I've got two different theories and I'm wondering if either is on base. Theory 1 I achieve the cropping by drawing into an offscreen image context of my target size. Since I want the center portion of the image I set the CGRect argument passed to drawInRect to something that's larger than the bounds of my.. size. Since I want the center portion of the image I set the CGRect argument passed to drawInRect to something that's larger than the bounds of my image context. I was hoping this was Kosher but am I instead attempting to draw over other memory that I shouldn't be touching Theory 2 I'm doing all of this in a background..
How do I export UIImage array as a movie? http://stackoverflow.com/questions/3741323/how-do-i-export-uiimage-array-as-a-movie 0 void pxdata CVPixelBufferGetBaseAddress pxbuffer NSParameterAssert pxdata NULL CGColorSpaceRef rgbColorSpace CGColorSpaceCreateDeviceRGB CGContextRef context CGBitmapContextCreate pxdata frameSize.width frameSize.height 8 4 frameSize.width rgbColorSpace kCGImageAlphaNoneSkipFirst NSParameterAssert context CGContextConcatCTM.. context CGBitmapContextCreate pxdata frameSize.width frameSize.height 8 4 frameSize.width rgbColorSpace kCGImageAlphaNoneSkipFirst NSParameterAssert context CGContextConcatCTM context frameTransform CGContextDrawImage context CGRectMake 0 0 CGImageGetWidth image CGImageGetHeight image image CGColorSpaceRelease rgbColorSpace.. pxdata frameSize.width frameSize.height 8 4 frameSize.width rgbColorSpace kCGImageAlphaNoneSkipFirst NSParameterAssert context CGContextConcatCTM context frameTransform CGContextDrawImage context CGRectMake 0 0 CGImageGetWidth image CGImageGetHeight image image CGColorSpaceRelease rgbColorSpace CGContextRelease context..
Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints? http://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints cropping up. UIImage Method PDF's in a UIImage don't optically scale as well as a Layer approach. The CPU and memory hit on generating the UIImages from a PDFcontext limits prevents using it to create a real time render of new zoom levels. CATiledLayer Method Theres a significant Overhead time drawing a full PDF page to a CALayer.. is a bad idea memory wrap the docRef into a singleton. Cancel needless NSOperations When you can especially if they will be using memory beware of leaving contexts open though Recycle page objects by doing pointer swaps or destroy unused views Close any open Contexts as soon as you don't need them on receiving memory warnings.. the user start zooming I acquire the CGPDFPage and render it using the appropriate CTM. The code in void drawLayer CALayer layer inContext CGContextRef context is like CGAffineTransform currentCTM CGContextGetCTM context if currentCTM.a 1.0 baseImage Calculate ideal scale CGFloat scaleForWidth baseImage.size.width self.bounds.size.width..
iOS UIImagePickerController result image orientation after upload http://stackoverflow.com/questions/5427656/ios-uiimagepickercontroller-result-image-orientation-after-upload UIImageOrientationUp case UIImageOrientationDown case UIImageOrientationLeft case UIImageOrientationRight break Now we draw the underlying CGImage into a new context applying the transform calculated above. CGContextRef ctx CGBitmapContextCreate NULL self.size.width self.size.height CGImageGetBitsPerComponent self.CGImage.. break default CGContextDrawImage ctx CGRectMake 0 0 self.size.width self.size.height self.CGImage break And now we just create a new UIImage from the drawing context CGImageRef cgimg CGBitmapContextCreateImage ctx UIImage img UIImage imageWithCGImage cgimg CGContextRelease ctx CGImageRelease cgimg return img @end share improve..
How to make a UITextField move up when keyboard is present http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present the view up down whenever the keyboard is shown dismissed void setViewMovedUp BOOL movedUp UIView beginAnimations nil context NULL UIView setAnimationDuration 0.3 if you want to slide up the view CGRect rect self.view.frame if movedUp 1. move the..
Add UIPickerView & a Button in Action sheet - How? http://stackoverflow.com/questions/1262574/add-uipickerview-a-button-in-action-sheet-how its hierarchy I recommend against trying to customize the contents of an ActionSheet as it can lead to serious invalid context errors in iOS 7. I just spent a few hours working through this problem and ultimately decided to take a different approach...
How to Rotate a UIImage 90 degrees? http://stackoverflow.com/questions/1315251/how-to-rotate-a-uiimage-90-degrees M_PI 180 UIImage rotate UIImage src UIImageOrientation orientation UIGraphicsBeginImageContext src.size CGContextRef context UIGraphicsGetCurrentContext if orientation UIImageOrientationRight CGContextRotateCTM context radians 90 else if orientation.. src.size CGContextRef context UIGraphicsGetCurrentContext if orientation UIImageOrientationRight CGContextRotateCTM context radians 90 else if orientation UIImageOrientationLeft CGContextRotateCTM context radians 90 else if orientation UIImageOrientationDown.. CGContextRotateCTM context radians 90 else if orientation UIImageOrientationLeft CGContextRotateCTM context radians 90 else if orientation UIImageOrientationDown NOTHING else if orientation UIImageOrientationUp CGContextRotateCTM..
Cropping a UIImage http://stackoverflow.com/questions/158914/cropping-a-uiimage theories and I'm wondering if either is on base. Theory 1 I achieve the cropping by drawing into an offscreen image context of my target size. Since I want the center portion of the image I set the CGRect argument passed to drawInRect to something.. of the image I set the CGRect argument passed to drawInRect to something that's larger than the bounds of my image context. I was hoping this was Kosher but am I instead attempting to draw over other memory that I shouldn't be touching Theory..
How do I export UIImage array as a movie? http://stackoverflow.com/questions/3741323/how-do-i-export-uiimage-array-as-a-movie pxbuffer NSParameterAssert pxdata NULL CGColorSpaceRef rgbColorSpace CGColorSpaceCreateDeviceRGB CGContextRef context CGBitmapContextCreate pxdata frameSize.width frameSize.height 8 4 frameSize.width rgbColorSpace kCGImageAlphaNoneSkipFirst.. pxdata frameSize.width frameSize.height 8 4 frameSize.width rgbColorSpace kCGImageAlphaNoneSkipFirst NSParameterAssert context CGContextConcatCTM context frameTransform CGContextDrawImage context CGRectMake 0 0 CGImageGetWidth image CGImageGetHeight.. 8 4 frameSize.width rgbColorSpace kCGImageAlphaNoneSkipFirst NSParameterAssert context CGContextConcatCTM context frameTransform CGContextDrawImage context CGRectMake 0 0 CGImageGetWidth image CGImageGetHeight image image CGColorSpaceRelease..
Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints? http://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints UIImage don't optically scale as well as a Layer approach. The CPU and memory hit on generating the UIImages from a PDFcontext limits prevents using it to create a real time render of new zoom levels. CATiledLayer Method Theres a significant Overhead.. into a singleton. Cancel needless NSOperations When you can especially if they will be using memory beware of leaving contexts open though Recycle page objects by doing pointer swaps or destroy unused views Close any open Contexts as soon as you.. the CGPDFPage and render it using the appropriate CTM. The code in void drawLayer CALayer layer inContext CGContextRef context is like CGAffineTransform currentCTM CGContextGetCTM context if currentCTM.a 1.0 baseImage Calculate ideal scale CGFloat..
iOS UIImagePickerController result image orientation after upload http://stackoverflow.com/questions/5427656/ios-uiimagepickercontroller-result-image-orientation-after-upload case UIImageOrientationLeft case UIImageOrientationRight break Now we draw the underlying CGImage into a new context applying the transform calculated above. CGContextRef ctx CGBitmapContextCreate NULL self.size.width self.size.height .. 0 0 self.size.width self.size.height self.CGImage break And now we just create a new UIImage from the drawing context CGImageRef cgimg CGBitmapContextCreateImage ctx UIImage img UIImage imageWithCGImage cgimg CGContextRelease ctx CGImageRelease..
How can i create a PDF file programmatically in an iphone application? http://stackoverflow.com/questions/1360912/how-can-i-create-a-pdf-file-programmatically-in-an-iphone-application iphone share improve this question See pg 35 of Drawing with Quartz to see how to create a PDF Graphics Context. Some notes iPhoneOSNote If you want to create a PDF graphics context in an iPhone application make sure you also read œDrawing.. If you want to create a PDF graphics context in an iPhone application make sure you also read œDrawing to a Graphics Context in iPhone OS page 27 . You can write any content to a PDF that ™s appropriate for your application ”images text path drawing..
iPhone development: pointer being freed was not allocated http://stackoverflow.com/questions/1424210/iphone-development-pointer-being-freed-was-not-allocated CA Transaction observer_callback __CFRunLoopObserver unsigned long void CA Transaction commit CA Context commit_transaction CA Transaction CALayerDisplayIfNeeded CALayer _display CABackingStoreUpdate backing_callback CGContext.. commit_transaction CA Transaction CALayerDisplayIfNeeded CALayer _display CABackingStoreUpdate backing_callback CGContext void CALayer drawInContext UIView CALayerDelegate drawLayer inContext AvatarView drawRect AvatarView overlayPNG UIImageUtility.. Transaction CALayerDisplayIfNeeded CALayer _display CABackingStoreUpdate backing_callback CGContext void CALayer drawInContext UIView CALayerDelegate drawLayer inContext AvatarView drawRect AvatarView overlayPNG UIImageUtility createMaskOf UIGraphicsGetImageFromCurrentImageContext..
How to get the RGB values for a pixel on an image on the iphone http://stackoverflow.com/questions/144250/how-to-get-the-rgb-values-for-a-pixel-on-an-image-on-the-iphone 8 In my UIImage subclass I declared instance variables size_t bytesPerRow size_t byteCount size_t pixelCount CGContextRef context CGColorSpaceRef colorSpace UInt8 pixelByteData A pointer to an array of RGBA bytes in memory RPVW_RGBAPixel pixelData.. RGBA 8 bits per component. The source image format will be converted to the format specified here by CGBitmapContextCreate. self setContext CGBitmapContextCreate void pixelData self.size.width self.size.height RGBA_8_BIT bytesPerRow.. component. The source image format will be converted to the format specified here by CGBitmapContextCreate. self setContext CGBitmapContextCreate void pixelData self.size.width self.size.height RGBA_8_BIT bytesPerRow colorSpace kCGImageAlphaPremultipliedLast..
Drawing a PNG Image Into a Graphics Context for Blending Mode Manipulation http://stackoverflow.com/questions/1936644/drawing-a-png-image-into-a-graphics-context-for-blending-mode-manipulation a PNG Image Into a Graphics Context for Blending Mode Manipulation I need to draw a series of PNGs into a CG context so I can blend them together CGContextRef.. for Blending Mode Manipulation I need to draw a series of PNGs into a CG context so I can blend them together CGContextRef context UIGraphicsGetCurrentContext CGContextSetBlendMode context kCGBlendModeOverlay Currently I have my app working.. need to draw a series of PNGs into a CG context so I can blend them together CGContextRef context UIGraphicsGetCurrentContext CGContextSetBlendMode context kCGBlendModeOverlay Currently I have my app working based on just drawing each image as a..
Using CGContext to display a sprite sheet iPhone http://stackoverflow.com/questions/2863626/using-cgcontext-to-display-a-sprite-sheet-iphone CGContext to display a sprite sheet iPhone So I have a spritesheet in png format and have already worked out the coordinates for.. that will return a UIImage when passed the location information on the spritesheet. I'm just not sure how to use the CGContext stuff along with the the coordinates to return an UIImage. I was looking to CGContextClipToRect because I think that is.. just not sure how to use the CGContext stuff along with the the coordinates to return an UIImage. I was looking to CGContextClipToRect because I think that is the way to do it but I just can't seem to get it to work. Something like this CGSize size..
iOS SDK - Programmatically generate a PDF file http://stackoverflow.com/questions/4362734/ios-sdk-programmatically-generate-a-pdf-file other objects will be placed. void CreatePDFFile CGRect pageRect const char filename This code block sets up our PDF Context so that we can draw to it CGContextRef pdfContext CFStringRef path CFURLRef url CFMutableDictionaryRef myDictionary NULL.. CreatePDFFile CGRect pageRect const char filename This code block sets up our PDF Context so that we can draw to it CGContextRef pdfContext CFStringRef path CFURLRef url CFMutableDictionaryRef myDictionary NULL Create a CFString from the filename.. CGRect pageRect const char filename This code block sets up our PDF Context so that we can draw to it CGContextRef pdfContext CFStringRef path CFURLRef url CFMutableDictionaryRef myDictionary NULL Create a CFString from the filename we provide to..
layer.renderInContext doesn't take layer.mask into account? http://stackoverflow.com/questions/4896296/layer-renderincontext-doesnt-take-layer-mask-into-account doesn't take layer.mask into account I'm trying to render some UIImages into 1 single image that I can save in my photo.. to render some UIImages into 1 single image that I can save in my photo album. But it seems to as if the layer.renderInContext doesn't take a layermask into account Current behavior the photo saves and I see mosaicLayer without the masking effect.. imageView addSubview mosaicLayer And then i use this code to save my composed image UIGraphicsBeginImageContext imageView.bounds.size imageView.layer renderInContext UIGraphicsGetCurrentContext UIImage saver UIGraphicsGetImageFromCurrentImageContext..
Invoke native date picker from web-app on iOS/Android http://stackoverflow.com/questions/4946919/invoke-native-date-picker-from-web-app-on-ios-android 1.5 Android plugin in Cordova 1.6 then in the Java code replace final PhonegapActivity currentCtx ctx with final Context currentCtx ctx.getContext and in the JavaScript file replace PhoneGap with cordova . Also note that GitHub sometimes renders.. Cordova 1.6 then in the Java code replace final PhonegapActivity currentCtx ctx with final Context currentCtx ctx.getContext and in the JavaScript file replace PhoneGap with cordova . Also note that GitHub sometimes renders README.md wrong see its..
Convert html file to PDF Document in iOS using Cocoa-Touch http://stackoverflow.com/questions/6316192/convert-html-file-to-pdf-document-in-ios-using-cocoa-touch be the name of our pdf file void CreatePDFFile CGRect pageRect const char filename This code block sets up our PDF Context so that we can draw to it CGContextRef pdfContext CFStringRef path CFURLRef url CFMutableDictionaryRef myDictionary NULL.. CreatePDFFile CGRect pageRect const char filename This code block sets up our PDF Context so that we can draw to it CGContextRef pdfContext CFStringRef path CFURLRef url CFMutableDictionaryRef myDictionary NULL Create a CFString from the filename.. CGRect pageRect const char filename This code block sets up our PDF Context so that we can draw to it CGContextRef pdfContext CFStringRef path CFURLRef url CFMutableDictionaryRef myDictionary NULL Create a CFString from the filename we provide to..
Xcode 4.2 Warnings when dropping Nav Controller on Tab Bar in IB http://stackoverflow.com/questions/7625731/xcode-4-2-warnings-when-dropping-nav-controller-on-tab-bar-in-ib a UINavigationController onto a UITabBar I get these two warnings warning Attribute Unavailable Defines Presentation Context is not available prior to Xcode 4.2. warning Attribute Unavailable Defines Presentation Context on iOS versions prior to.. Defines Presentation Context is not available prior to Xcode 4.2. warning Attribute Unavailable Defines Presentation Context on iOS versions prior to 5.0. The UINavigationController functions as expected in fact the entire app runs perfectly. But.. the warnings disappear. iphone xcode4 ios4 ios5 xcode4.2 share improve this question Just uncheck the Defines Context checkbox in the attributes inspector. Double click on MainWindow.xib select the navigation controller then go to View Utilities..
iCloud basics and code sample [closed] http://stackoverflow.com/questions/7795629/icloud-basics-and-code-sample see the big picture. So please bear with me some of these questions are quite fundamental but possibly easy to answer. Context I have a very simple iCloud app running full sample code below . There is only one UITextView shown to the user and his..
Which weather data web services do you know? http://stackoverflow.com/questions/8446360/which-weather-data-web-services-do-you-know You must ask for a quote . Offers XML JSON and some other formats. SimpleGeo Offered weather data as part of their Geo Context. Got acquired by Urban Airship and may change their plans . yr.no Norwegian Meteorological Institute met.no and the Norwegian..
UIView: how to do non-destructive drawing? http://stackoverflow.com/questions/865636/uiview-how-to-do-non-destructive-drawing whenever drawRect is called. You cannot prevent the contents from being erased by doing the following self setClearsContextBeforeDrawing NO This is merely a hint to the graphics engine that there is no point in having it pre clear the view for.. coder if self super initWithCoder coder self.backgroundColor UIColor clearColor CGSize size self.frame.size drawingContext self createDrawingBufferContext size return self CGContextRef createOffscreenContext CGSize size CGColorSpaceRef colorSpace.. coder self.backgroundColor UIColor clearColor CGSize size self.frame.size drawingContext self createDrawingBufferContext size return self CGContextRef createOffscreenContext CGSize size CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB..
|