我有一個應用程序,它使用UIImagePickerController來允許用戶拍照。UIImagePicker崩潰在ios7/iphone 4s
我已經將測試用例簡化爲單個視圖控制器應用程序中最簡單的順序。這是我的代碼。
//
// CTViewController.h
// Camera Test
//
#import <UIKit/UIKit.h>
@interface CTViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
@property (nonatomic, retain) UIImagePickerController *cameraController;
- (IBAction)takePicture:(id)sender;
@end
代碼的體如下:
//
// CTViewController.m
// Camera Test
#import "CTViewController.h"
....
- (void)didReceiveMemoryWarning
{
NSLog(@"%s", __func__);
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)takePicture:(id)sender
{
self.cameraController = [[UIImagePickerController alloc] init];
self.cameraController.sourceType = UIImagePickerControllerSourceTypeCamera;
self.cameraController.allowsEditing = YES;
self.cameraController.delegate = self;
[self presentViewController:self.cameraController animated:YES completion:nil];
}
「takePicture」被掛接到一個按鈕,我可以在屏幕的中間壓。
在ios 6上一切正常,但在ios 7上,一旦viewcontroller出現,我會得到一連串的內存警告。因此:
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.
Received memory warning.
-[CTViewController didReceiveMemoryWarning]
.... <here I take a picture, which I do nothing with>
Received memory warning.
-[CTViewController didReceiveMemoryWarning]
Received memory warning.
-[CTViewController didReceiveMemoryWarning]
.... <I get a cascade of these warnings>
的應用程序使用的IOS,如果我建立一個與IOS 6.1的SDK,但ios7運行7.0 SDK使用Xcode的5同樣的問題時建造的。使用ios 6.1 sdk構建並在ios 6.1.3上運行不會導致任何消息和問題。
我的完整應用程序在ios 7上崩潰了50%。我通過拋出大量內容(圖像大多數)內存不足和分析來回應內存警告,但我仍然得到警告級聯(即在內存釋放後它們繼續)。
如果我使用前置攝像頭,從圖庫中選擇或使用iPad 3,則沒有消息。因此,當使用後置攝像頭時,我懷疑內存問題與UIImagePickerController的大小有關。
我有充分的探討和計算器都顯得格外這個帖子 - UIImagePickerController error: Snapshotting a view that has not been rendered results in an empty snapshot in iOS 7
我已經試過各種建議,但我的簡單測試應用程序阻止大多數的解釋。
有什麼想法?我應該放棄對iPhone 4S的支持嗎?我還沒有確認iPhone 5的問題,但我會盡快更新這個問題。
:-)
在iOS7上查看並接受iPhone 4s上的照片後,我們也遇到了相機崩潰的相同問題。 –
這很奇怪,所以我不提供它作爲答案。我有完全相同的問題,但在iPhone 5s上。花費4個小時來解決堆棧溢出問題。最後,我重新啓動了我的iPhone 5s,並且沒有更多的內存警告。他們可能會回來,但與問題應用程序拍攝2小時後,仍然沒有記憶警告。奇怪的! – JimVision
這似乎「修復」它。這到底是什麼...... –