調用系統相機出現問題

http://www.4byte.cn/question/474924/uiimagepickercontroller-error-snapshotting-a-view-that-has-not-been-rendered-results-in-an-empty-snapshot-in-ios-7.html


我只是在iOS 7得到這個錯誤,應用程序崩潰。在iOS 6,我從來沒有任何錯誤,只是曾經的記憶時,打開警告。

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.

這是我做的。

imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setDelegate:self];
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setAllowsEditing:YES];

[self presentModalViewController:imagePicker animated:YES];

我試圖延遲presentmodalviewcontroller,但我仍然得到同樣的信息。幾秒鐘後(7-10),該應用程序崩潰。

這個錯誤是目前唯一在iOS 7。

任何人都有線索嗎?謝謝你在前進。

在ios7問題都與轉換。看來,如果之前的過渡不完整,你推出一個新的觀點,ios7混亂,在iOS6似乎正確地管理它。

你應該在你初始化你的相機UIViewController,只有在觀念已經裝載和超時:

- (void)viewDidAppear:(BOOL)animated 
{
    [super viewDidAppear:animated];
    //show camera...
    if (!hasLoadedCamera)
        [self performSelector:@selector(showcamera) withObject:nil afterDelay:0.3];
}

這裏是初始化代碼

- (void)showcamera {
    imagePicker = [[UIImagePickerController alloc] init];
    [imagePicker setDelegate:self];
    [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
    [imagePicker setAllowsEditing:YES];

    [self presentModalViewController:imagePicker animated:YES];
}
也許這不是一個解決你的問題卻依然。presentModalViewController:animated:在iOS 6不贊成。以目前的一個模態視圖,使用presentViewController:animated:completion:而不是。你可以通過nil爲完成處理程序,如果你沒有什麼後做viewDidAppear:的方法被提出的視圖控制器。


也許這不是一個解決你的問題卻依然。presentModalViewController:animated:在iOS 6不贊成。以目前的一個模態視圖,使用presentViewController:animated:completion:而不是。你可以通過nil爲完成處理程序,如果你沒有什麼後做viewDidAppear:的方法被提出的視圖控制器。

試試這個,使用

[self performSelector:@selector(presentCameraView) withObject:nil afterDelay:1.0f];

和功能

-(void)presentCameraView{
    [self presentViewController:imagePicker animated:YES completion:nil];
}

代替。[self presentModalViewController:imagePicker animated:YES];和事業作出imagePicker作爲一個全局變量。


我在建築應用的iOS SDK 6.1得到這個錯誤,部署目標iOS 6.1和iOS 7供電的iPhone上運行的應用程序。應用程序不會崩潰,但實現UIViewController shouldAutorotate的方法幫助我去除錯誤消息。

- (BOOL)shouldAutorotate {
    return YES;
}


這是什麼固定爲我的應用程序,你的方法可能是不同的

首先,它是一個iPhone,ipad應用

在appname-info.plist。在支持界面取向(ipad)顯示4個方向。

在支持的接口方向顯示的3個方向。我加了第四把應用程序,沒有調試輸出。

希望這會有所幫助。

我有問題時,我試圖把相機視圖內的一個鬆餅。在iOS6這沒有問題但在ios7我得到的消息

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.

好。

然而在我改變了相機的視角呈現全屏介紹攝影和電影,iOS開發者圖書館一切都很好,又和消息再沒有出現。但是我必須保證根據該模式應用程序(即,將相機視圖或照片卷)我不得不要麼駁回烤餅或視圖控制器的方法時- (void) imagePickerControllerDidCancel: (UIImagePickerController *) picker被稱爲。



這個錯誤也出現在我的蘋果photopicker示例代碼項目。

我是用Xcode 5版和iOS 7.0.3在iPhone 4。

重現步驟:

  1. 下載蘋果的photopicker樣本項目https://developer.apple.com/library/ios/samplecode/photopicker/introduction/intro.html

  2. 在aplviewcontroller M註釋掉線125。

    / / imagepickercontroller.showscameracontrols =不;

  3. 在aplviewcontroller。M註釋掉線130-133.

    / / [ [ nsbundle mainbundle ] loadnibnamed:”“overlayview”業主:自我選擇:零];

    / / self.overlayview.frame = imagepickercontroller.cameraoverlayview.frame;

    / / imagepickercontroller.cameraoverlayview = self.overlayview;

    / / self.overlayview = nil;

  4. 建立和啓動應用程序。

  5. 一旦啓動,旋轉到景觀模式的裝置。

  6. 點擊相機圖標在相機模式打開uiimagepickercontroller。

  7. 查看控制檯輸出。

控制檯輸出

photopicker [ 240:60b ]照片一看,不是在一個空的快照被渲染的結果。確保你的觀點已經呈現之前至少有一次快照或快照後,屏幕更新。

showscameracontrols財產

問題發生時給我這個有價值的是(默認)。

設置這個沒有消除消息。

錯誤報告

我只是向蘋果的錯誤報告。

我試過許多已經在不同的崗位,提出的建議,但沒有找到一個滿意的解決方法。

我也有同樣的問題時,我試圖修改來與應用程序的演示avirary SDK,在演示應用程序,它只能編輯挑選從相機的照片。試圖通過捕獲從相機編輯照片,我第一次添加以下代碼中的M文件的處理:

#pragma mark - Take Picture from Camera
- (void)showCamera
{
//[self launchPhotoEditorWithImage:sampleImage highResolutionImage:nil];

    if ([self hasValidAPIKey]) {
        UIImagePickerController * imagePicker = [UIImagePickerController new];
        [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
        [imagePicker setDelegate:self];
        [imagePicker setAllowsEditing:YES]; //important, must have

        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
            [self presentViewController:imagePicker animated:YES completion:nil];
        }else{
            [self presentViewControllerInPopover:imagePicker];
        }
    }
}

當我運行的應用程序,錯誤發生:

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.

爲了解決錯誤,修改uiimagepicker代表你的uiviewcontooler M文件,如下所示:

#pragma mark - UIImagePicker Delegate

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSURL * assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];

    void(^completion)(void)  = ^(void){

        [[self assetLibrary] assetForURL:assetURL resultBlock:^(ALAsset *asset) {
            if (asset){
                [self launchEditorWithAsset:asset];
            }
        } failureBlock:^(NSError *error) {
            [[[UIAlertView alloc] initWithTitle:@"Error" message:@"Please enable access to your device's photos." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
        }];

        UIImage * editedImage = [info objectForKey:UIImagePickerControllerEditedImage];
        if(editedImage){
            [self launchPhotoEditorWithImage:editedImage highResolutionImage:editedImage];
        }

    };

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
        [self dismissViewControllerAnimated:YES completion:completion];
    }else{
        [self dismissPopoverWithCompletion:completion];
    }

}    

那麼錯誤消失,應用工程!


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章