2

アプリでカメラを開くと正常に動作しますが、アプリでナビゲートしてカメラ ビューに戻り、iPad でカメラを開こうとすると、アプリがクラッシュし、「受信メモリ警告」が表示されます。アプリは iPhone で正常に動作し、この問題は iPad でのみ発生します。

私のプロジェクトには ARC がなかったので、良い結果が得られることを期待してプロジェクトを ARC に変換しましたが、ナビゲーションがほとんどなくてもアプリがカメラでクラッシュします。私のアプリがメモリ警告を受け取らないように、iPadカメラでメモリスペースを減らす方法を誰か教えてください。

これはカメラの私のコードです

if ([UIImagePickerController isSourceTypeAvailable:
         UIImagePickerControllerSourceTypeCamera])
    {
        imagePicker=[[UIImagePickerController alloc] init];
        imagePicker.delegate = self;
        imagePicker.sourceType =UIImagePickerControllerSourceTypeCamera;
        imagePicker.allowsEditing = NO;
        //imagePicker.modalPresentationStyle = UIModalPresentationFullScreen;

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

これが私のイメージを取得する場所です

-(void)imagePickerController:(UIImagePickerController *)picker     didFinishPickingMediaWithInfo:(NSDictionary *)info
{
        [Array removeAllObjects];

        [picker dismissViewControllerAnimated:YES completion:nil];
        image = [info objectForKey:UIImagePickerControllerOriginalImage];

        [array addObject:image];
        image=nil;

}

また、カメラにpopOverviewを使用しようとしましたが、うまくいきませんでした。

UIImagePickerController を呼び出している viewController では、viewWillAppear でアニメーションを呼び出す前に 5 つのアニメーションを使用しましたが、アプリがクラッシュしていたので、アニメーションの呼び出しを ViewDidLoad に変更し、カメラが機能し始めましたが、最後のビューに移動して戻ってくるまでのみでした。もう一度カメラを開きます。

4

3 に答える 3

2

Try to run your app without animation and then try, if it works then you need to improve your animations memory allocation, as animation needs a lot of memory.

于 2013-08-21T12:16:06.567 に答える
0

以下のコードを試してくださいUIImagePickerController。ポップオーバーで試してください

if([UIImagePickerContrller isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
        UIImagePickerController *controller = [[UIImagePickerController alloc] init];
        controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        controller.allowsEditing = YES;
        controller.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
        controller.delegate = self;
        UIPopoverController *popController = [[UIPopoverController alloc]  initWithContentViewController:controller];
        popController.popoverContentSize = CGSizeMake(350.0f, 500);
        [popController presentPopoverFromRect: self.button.frame inView:self.button.superview
                     permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES]
}
于 2013-08-21T09:31:24.340 に答える