Because I also reported this warning, I wrote the solution to this place to see if other people have used it. The specific solution:
Error code:Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.
Problem analysis:When iOS8 calls the system camera to take pictures, it will pause for one or two seconds, and then the UIImagePickConroller pops up. IOS7 does not have this problem. I have searched it on Baidu countless times but failed to solve this problem. Some say that the imagePickController needs to be set as a global variable, some say that the time delay is 0.5 seconds and then presentViewController is displayed. They all show their magical powers, but unfortunately, they cannot solve this problem. Today I wrote a demo to study this problem, and finally made breakthrough progress!
In fact, the fundamental reason is not on the system photo controller, but on the action of executing the presentViewController itself! We can check the UIViewController class, which has a property:
@property(nonatomic,assign) UIModalPresentationStyle modalPresentationStyle NS_AVAILABLE_IOS(3_2);
This is an enum value, defined in the iOS7 SDK as follows:
typedefNS_ENUM(NSInteger, UIModalPresentationStyle) { UIModalPresentationFullScreen = 0, #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2 UIModalPresentationPageSheet, UIModalPresentationFormSheet, UIModalPresentationCurrentContext, #endif #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0 UIModalPresentationCustom, UIModalPresentationNone = -1, #endif };
The iOS8 SDK is defined as follows:
typedefNS_ENUM(NSInteger, UIModalPresentationStyle) { UIModalPresentationFullScreen = 0, UIModalPresentationPageSheetNS_ENUM_AVAILABLE_IOS(3_2), UIModalPresentationFormSheetNS_ENUM_AVAILABLE_IOS(3_2), UIModalPresentationCurrentContextNS_ENUM_AVAILABLE_IOS(3_2), UIModalPresentationCustomNS_ENUM_AVAILABLE_IOS(7_0), UIModalPresentationOverFullScreenNS_ENUM_AVAILABLE_IOS(8_0), UIModalPresentationOverCurrentContextNS_ENUM_AVAILABLE_IOS(8_0), UIModalPresentationPopoverNS_ENUM_AVAILABLE_IOS(8_0), UIModalPresentationNoneNS_ENUM_AVAILABLE_IOS(7_0) = -1, };
The key part of solving the problem is here. IOS8 has an additional style UIModalPresentationOverCurrentContext. When presentViewController in IOS8, please set the controller's modalPresentationStyle to UIModalPresentationOverCurrentContext.Problem solved! !
if([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0) { =UIModalPresentationOverCurrentContext; }
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.