由於我這也報了這個正告,所以把處理辦法寫到這個中央看能否其別人用的到,詳細處理辦法:
錯誤代碼: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.
問題剖析:IOS8在調用零碎相機拍照時,會有一兩秒的進展,然後再彈出UIImagePickConroller,IOS7是沒有這個問題的,在百度找了有數遍都沒能處理這個問題,有說要將imagePickController設置為全局變量,有說要延時0.5秒再presentViewController的,各顯神通,但很遺憾的都沒能處理這個問題,明天特意獨自寫個Demo來研討此問題,終於獲得了打破性的停頓!
其實基本緣由不在於零碎拍照控制器下面,而是執行presentViewController這個舉措自身!我們可以檢查下UIViewController這個類,他有一個屬性:
@property(nonatomic,assign) UIModalPresentationStyle modalPresentationStyle NS_AVAILABLE_IOS(3_2);
這是一個枚舉值,在iOS7的SDK中,定義如下:
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 };
在iOS8的SDK中定義如下:
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, };
處理問題的關鍵局部來了,IOS8多了一個款式UIModalPresentationOverCurrentContext,IOS8中presentViewController時請將控制器的modalPresentationStyle設置為UIModalPresentationOverCurrentContext,問題處理!!
if([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0) { self.modalPresentationStyle=UIModalPresentationOverCurrentContext; }
以上就是本文的全部內容,希望對大家的學習有所協助,也希望大家多多支持本站。
【iOS8調用相機報正告Snapshotting a view的處理辦法】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!