내 앱에서 전체 화면 UIImagePickerController를 구현하려고합니다. presenting view controllers on detached view controllers is discouraged
때문에보기 컨트롤러를 viewDidLoad
에 표시 할 수 없습니다. 그러나 내 viewDidAppear
은 무한히 호출되며 이미지 선택 관리자 컨트롤러가 추가되고 각 호출마다 화면에서 삭제됩니다. 메인 대기열로 디스패치를 시도했지만 문제가 해결되지 않았습니다.presentViewController는 viewDidAppear에서 무한대로 호출됩니다.
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
ipc = [[UIImagePickerController alloc] init];
ipc.delegate = self;
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
ipc.sourceType = UIImagePickerControllerSourceTypeCamera;
ipc.showsCameraControls = NO;
CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 71.0);
ipc.cameraViewTransform = translate;
CGAffineTransform scale = CGAffineTransformScale(translate, 1.333333, 1.333333);
ipc.cameraViewTransform = scale;
ipc.showsCameraControls = NO;
ipc.tabBarController.tabBar.hidden = YES;
ipc.allowsEditing = NO;
[self presentViewController:ipc animated:YES completion:nil];
}
}
#pragma mark - ImagePickerController Delegate
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage* theImage = [info objectForKey:UIImagePickerControllerOriginalImage];
if(picker.sourceType == UIImagePickerControllerSourceTypeCamera)
{
UIImageWriteToSavedPhotosAlbum(theImage, nil, nil, nil);
}
int height = -1;
if([[NSUserDefaults standardUserDefaults] integerForKey:@"reduce_image"] == 0){
height = 640;
} else if ([[NSUserDefaults standardUserDefaults] integerForKey:@"reduce_image"] == 1) {
height = 1024;
} else {
height = 1600;
}
UIImage* resizedImageForUpload = [UtilityFunctions scaleAndRotateImage:theImage maxResolution:height];
NSData* imageDataForUpload = UIImageJPEGRepresentation(resizedImageForUpload, 1); // reduced image! //
NSString *userDataset = [UtilityFunctions retrieveFromUserDefaults:@"dataset"];
[self didPickImage:imageDataForUpload atLocation:currentLocation
userDataset: userDataset];
[picker dismissViewControllerAnimated:YES completion:nil];
[mLocationManager stopUpdatingLocation];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
/*navigate to home tab*/
[picker dismissViewControllerAnimated:YES completion:nil];
self.tabBarController.tabBar.hidden = NO;
[self.tabBarController setSelectedIndex:0];
}
내 문제는 코드의 다른 부분에있는 것 같습니다. ipc의 델리게이트 메소드에서는 무엇을하고 있습니까? – onnoweb
이 델리게이트 메소드로 업데이트되었습니다 :) – Matt
선택기'dismissViewControllerAnimated'에 중단 점을 설정하는 것이 도움이 될 수 있습니다. 나는 그것이 우연히 해산된다고 생각한다. – mschmidt