Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iImagePicker在ios7/iphone 4s上崩溃_Iphone_Ios_Objective C_Ios7 - Fatal编程技术网

iImagePicker在ios7/iphone 4s上崩溃

iImagePicker在ios7/iphone 4s上崩溃,iphone,ios,objective-c,ios7,Iphone,Ios,Objective C,Ios7,我有一个应用程序,它使用UIImagePickerController允许用户拍照 我已经将测试用例简化为单视图控制器应用程序中最简单的序列。这是我的密码 // // CTViewController.h // Camera Test // #import <UIKit/UIKit.h> @interface CTViewController : UIViewController <UINavigationControllerDelegate, UIImagePic

我有一个应用程序,它使用UIImagePickerController允许用户拍照

我已经将测试用例简化为单视图控制器应用程序中最简单的序列。这是我的密码

//
//  CTViewController.h
//  Camera Test
//

#import <UIKit/UIKit.h>

@interface CTViewController : UIViewController <UINavigationControllerDelegate,   UIImagePickerControllerDelegate>

@property (nonatomic, retain) UIImagePickerController *cameraController;

- (IBAction)takePicture:(id)sender;

@end
'PuxPix'被连接到一个按钮,我可以按下屏幕中间。

在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>
对尚未渲染的视图进行快照会导致快照为空。确保您的视图在快照之前或屏幕更新之后至少呈现一次。
收到内存警告。
-[CTViewController未收到内存警告]
.... 
收到内存警告。
-[CTViewController未收到内存警告]
收到内存警告。
-[CTViewController未收到内存警告]
.... 
该应用程序是使用ios 7.0 sdk和xcode 5构建的。如果我使用ios 6.1 sdk构建,但在ios 7上运行,也会出现同样的问题。使用ios 6.1 sdk构建并在ios 6.1.3上运行不会导致任何消息和问题

我的完整应用程序在ios 7上50%的时间崩溃。对于内存警告,我会将大量内容(主要是图像)抛出内存,并通过分析确认这一点,但我仍然会收到层叠的警告(即,在内存释放后,它们会继续)

如果我使用前置摄像头、从多媒体资料中选择或使用iPad3,则不会显示任何信息。因此,我怀疑内存问题与使用后置摄像头时UIImagePickerController的大小有关

我已经充分探讨了stackoverflow,并特别关注了这篇文章-

我尝试了所有建议,但我的简单测试应用程序排除了大多数解释

有什么想法吗?我应该放弃对iphone4s的支持吗?我还没有确认iPhone5上的问题,但我会尽快更新这个问题


:-)

我建议您不要为图像选择器使用属性,而是使用本地对象。请参阅下面我的代码,它在IOS7上也可以正常工作

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    imagePicker.showsCameraControls = YES;

    [self presentViewController:imagePicker animated:YES completion:nil];
}

你能详细说明这个建议吗?我有一个带有自定义套印的应用程序,我将imagePicker的一个ref传递到套印控制器,这样我就可以调用套印IBAction内的takePhoto:[self.camerapickeref takePicture]另外,当我切换相机设备时,我会在self.imagePicker.view中添加一个自定义的黑色子视图,这样过渡会更好一些。在这种方法中,我需要一个对imagePicker的引用来添加子视图并设置相机设备。这样一来,一旦你拍照,它就会被取消分配,但是如果你需要一个强引用,它会更复杂。好吧,我想我的CameraOverlyViewController中的强引用可以消除,但我仍然需要CameraOverlyViewController中的选择器的引用,这样我就可以实际调用takePhoto。我只是不确定消除强ref是否是治疗方法,特别是因为这是iphone4s特有的。我热衷于在适当的位置设置self.imagePicker=nil。我遇到了同样的问题,我也尝试过这两个SDK版本。它只在iPhone4 iOS7上提供内存警告,但在iPhone4 iOS7上,它大部分时间都会崩溃。我们也遇到了同样的问题,在使用iOS7查看并接受iPhone 4s上的照片后,相机会崩溃。这很奇怪,所以我不提供答案。我有完全相同的问题,但在iphone5s上。花4个小时倒在堆垛溢出物上,四处打听。最后,我重新启动了我的iphone5s,并没有更多的内存警告。他们可能会回来,但使用有问题的应用程序拍照2小时后,仍然没有内存警告。奇怪的这似乎“修复”了它。这到底是怎么回事……可能是因为ios7试图拍摄你的应用的快照视图,以便在控制面板上显示它。我花了半天时间调试它,Jim的重启答案解决了这个问题。。。吉姆,请把它作为答案提交!
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    imagePicker.showsCameraControls = YES;

    [self presentViewController:imagePicker animated:YES completion:nil];
}