When the iPad changes orientation, I uninstall the view in the old orientation And load the view in the new orientation. So say it is in portrait view and then change to landscape. The application uninstalls the portrait view and loads the landscape view. This all works well, unless the pdf is large.
pdf is used tileslayers is drawn. When the orientation is changed to a large pdf, the application is cleaning up. If the orientation is changed before all the tiles are drawn, the application will only crash. My guess is that it crashed because it tried to convert the tiles Draw to view instead of unloaded. So is there a way to stop drawing tiles when I unload the view?
This will stop rendering and you can safely release it later.
- (void)stopTiledRenderingAndRemoveFromSuperlayer; {
((CATiledLayer *)[self layer] ).delegate = nil;
[self removeFromSuperview];
[self.layer removeFromSuperlayer];
}
Also, please make sure to call this method from the main thread, Otherwise there may be horrible errors.
I have a pdf reader app for iPad and I use scroll view to display each page. I keep the page In view, and view a page on either side of the page. I have separate views for portrait and landscape views. Portrait view shows a single page, and landscape viewer shows 2 pages.
When When the iPad changes its orientation, I will unload the view in the old orientation and load the view in the new orientation. So say it is in portrait view and then change to landscape. The app unloads the portrait view and loads the landscape view. This all works well, unless the pdf is very good Large.
The pdf is drawn using tileslayers. When the orientation is changed to a large pdf, the application is cleaning up. If the orientation is changed before all the tiles are drawn, the application will only crash. I My guess is that it crashed because it tried to draw the tiles to the view instead of being unloaded. So is there a way to stop drawing the tiles when I unload the view?
You need to set CALayer’s delegate to nil and then remove it from the superview.
This will stop rendering, after which you can safely release .
- (void)stopTiledRenderingAndRemoveFromSuperlayer; {
((CATiledLayer *)[self layer]).delegate = nil;
[self removeFromSuperview];
[self.layer removeFromSuperlayer];
}
Also, make sure to call this method from the main thread, otherwise terrible errors may occur.