I create small fragments of an image that will be stored on disk and displayed to the user. Here is my current process for doing this:
- Create a view manager representing the user interface I want to show on the screen
- Get view from view manager and display image from it
- Save it to disk and display it later.
I am trying to access viewcontroller view. When I tried to explore this online resource, I get conflicting results about whether it is safe to create a view in the background. I read that calling UIGraphicsGetCurrentContext should be thread safe, but maybe not access the UIView in the background thread? I am writing an application for iOS 4 and above. Here is the code I'm using (tile - viewcontroller):
CGSize size = CGSizeMake(20.0f, 30.0f); UIGraphicsBeginImageContext(size); [tile.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
The crash occurs when trying to access the .view property on the tile (EXC_BAD_ACCESS). The thing is to render the image in the background in order to prevent the user interface from being blocked, since processing requires a lot of fragments.
Is there a safe way to do this?
source share