MortimerGoro/MGSwipeTableCell

Swift 3, content in cell disappears as you swipe (device only) with error: CGImageCreateWithImageProvider: invalid image provider: NULL.

carien opened this issue · 1 comments

I am experiencing the following behavior using Swift 3 running to device with iOS 9.3 using MGSwipeTableCell 1.5.5.

When running my app on the device, the content of the tableview cell disappears as I swipe. (my cell takes up the entire view.) The same does not happen on the simulator. When the swipe is complete, everything is back to normal. I found by replacing
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
with
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
in imageFromView: fixes the bug for me.

This thread helped me to get to the solution.
http://stackoverflow.com/questions/34715561/how-to-capture-complete-screenshot-of-view-in-ios9/34715699

- (UIImage *)imageFromView:(UIView *)view {
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, [[UIScreen mainScreen] scale]);
//    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
    UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

One more thought. My cell contains a UIPageViewController that contains a WKWebView for each page. There are a few other questions on the web regarding screenshots of WKWebView not working the same on device as on simulator. I have not tested with other controls, so the WKWebView might be the only one that causes the problem.

Interesting, never tried to add a WKWebView in a cell. I'll try to reproduce the issue