Note that there are some explanatory texts on larger screens.

plurals
  1. POARC-aware UIImage from UIView
    primarykey
    data
    text
    <p>My application iterates through a directory of PDF-files, draws there first page into a off-screen UIView subclass using the CGPDF API functions, which makes a UIImage available to the application. The UIView subclass simply adds the <em>@property (nonatomic,assign) image</em>, which in its setter uses the standard way to get a UIImage from a UIView, as per Apple references.</p> <p>UIViewWithImage.h:</p> <pre><code>@interface UIViewWithImage : UIView { UIImage* image; } @property (nonatomic,strong) UIImage* image; @end </code></pre> <p>UIViewWithImage.m:</p> <pre><code>@implementation UIViewWithImage @dynamic image; -(UIImage*)image { if( [self.layer respondsToSelector:@selector(setShouldRasterize:)]) UIGraphicsBeginImageContextWithOptions( self.bounds.size, NO, self.contentScaleFactor ); else UIGraphicsBeginImageContext(self.bounds.size); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; } @end </code></pre> <p>So far, so good. My application uses ARC (automatic reference counting) and crashes in this method, short after memory warnings are received. There is no exception thrown, instruments was not of great help as I could not observe memory accumulations. Only removing the code from the setter saves the app from crashing.</p> <p>I have read a lot about bridging, which seems not applicable in my case. It seems to me that the code above allocates objects and never frees them, at least that will explain the memory warnings.</p> <p>Any help is appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload