2014/03/26

slove UIImagePickerController use on ios 7 crashes


Received memory warning 問題

  • 在 IOS6 中使用 UIImagePickerController 可正常運行,但在 IOS7 / iPhone 4S 中拍照時,卻出現

2014-03-25 16:45:39.990 CameraTest[3442:60b] Received memory warning.
  • 在拍照時,內存使用會較平常高出許多,所以在較低階的設備 ( pad min,iPad2 ) 執行時,有時甚至會導致 app crash

Slove

在 didReceiveMemoryWarning 中將佔用的資源釋放

- (void)didReceiveMemoryWarning
{
    [self.imagePicker dismissViewControllerAnimated:YES completion:^{}];  //釋放 UIImagePickerController
    [super didReceiveMemoryWarning];
}

Snapshotting a view that has not been rendered results... 問題

  • IOS7 再調用 UIImagePickerController 時,若 device 為橫向則會出現以下訊息

2014-03-25 16:47:48.824 CameraTest[3442:60b] 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.

Slove

  • 在 Apple Developer 中,可看到 The UIImagePickerController class supports portrait mode only. 故在橫向時,會出現如上訊息
  • 目前尚未找到有效的解決辦法,因為系統在開啟相機時會自動判斷 device 方向,且 device 方向是唯讀不可修改
  • 經過測試,上述訊息並不會影響 app 的運行,更不會導致 crash

References

沒有留言:

張貼留言