iOS软件开发

UIImagePickerController拍照后黑屏

2017-02-27  本文已影响54人  ekin_jenny

最近开发的一个项目中,UIImagePickerController拍照后黑屏,点击确认后也可以显示照片,而且每次黑屏出现的时候会有CGAffineTransformInvert: singular matrix错误信息。最初一直再上述错误中徘徊,找解决方案。查询多次,stackoverflow上各种可能的方法都试了,依然无果。百思不得其解!到底哪里出现了问题呢?

无奈,静下来,想,首先我要找到问题必然出现的原因,于是,经过反复测试,终于到到出现的点。项目中引入了一个三房库弹框JCAlterView,每次触发弹框后,在去拍照的地方必然出现预览黑屏的问题。试着把弹框改成自定义的之后,问题解决了!!本来开始想去修改JCAlterView底层。发现底层操作UIApplication的rootViewController了。无奈,最后直接自定义样式换了JCAlterView,问题解决了。

唯一遗憾的是,由于时间问题,我没有追究为何改变UIApplication的rootVIewController后再次拍照会出现黑屏错误。

附上stackoverflow的各种解决方法。

【链接】yourcommunities

http://stackoverflow.com/questions/25884801/ios-8-snapshotting-a-view-that-has-not-been-rendered-results-in-an-empty-snapsho

http://stackoverflow.com/questions/21538781/uiimagepickercontroller-camera-blank-snapshot-image

down vote

I found the solution to my problem thanks to DevC's comment pointing me in the right direction. I used an ActionSheet to present the UIImagePickerController, so when clicking a button on it the animation still runs while the picker is opened. I solved it by closing the picker before I run the code that triggers thepicker:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

[actionSheet dismissWithClickedButtonIndex:999 animated:NO]; //non-existing button index so it doesn't trigger anything again

// Rest of code here (UIImagePickerController trigger)

}

上一篇下一篇

猜你喜欢

热点阅读