国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

iOS8調用相機報警告Snapshotting a view的解決方法

2019-10-21 18:51:00
字體:
來源:轉載
供稿:網友

因為我這也報了這個警告,所以把解決方法寫到這個地方看是否其他人用的到,具體解決方法:

錯誤代碼: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;}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到IOS開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沛县| 盱眙县| 连城县| 仁寿县| 光泽县| 嘉义县| 水富县| 大宁县| 工布江达县| 罗江县| 多伦县| 东阿县| 合水县| 文成县| 博客| 靖宇县| 九江市| 泌阳县| 文山县| 桂阳县| 奉新县| 呼和浩特市| 上林县| 东至县| 称多县| 石首市| 通辽市| 澄江县| 郑州市| 香格里拉县| 醴陵市| 合作市| 永春县| 罗定市| 许昌市| 汝城县| 甘谷县| 龙海市| 新乡县| 新平| 广汉市|