2014-10-30 5 views
0

안녕하세요, 저는 프로젝트에서 일하고 있습니다. 사용자가 갤러리 나 카메라에서 이미지를 가져 오는 중입니다. 여기에서 코드를 제공하고 있습니다. 아이폰과 ipad, (ipad에서 작동하지 않는 갤러리에서 이미지를 찍을 때) 잘 작동합니다. 마지막 방법은 파일 이름을 인쇄 할 때 ipad에서 갤러리의 경우 그렇지 않으면 모든 경우에 정상적으로 작동합니다.ipad 갤러리에서 이미지 찍기

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{ 

[[UIApplication sharedApplication] setIdleTimerDisabled:NO]; 
NSString *_mediaType = [[info objectForKey:UIImagePickerControllerMediaType]copy]; 
if (fromPopvc==YES) { 

    if([_mediaType isEqualToString:(NSString *)kUTTypeImage]) { 
     [self fileName:[info objectForKey:UIImagePickerControllerOriginalImage] isImage:YES]; 
     [self showFileNameView]; 

     [popVC dismissPopoverAnimated:YES]; 
     fromPopvc=NO; 
    } 
} 
else { 
    if([_mediaType isEqualToString:(NSString *)kUTTypeMovie]) { 
     [self fileName:[info objectForKey:UIImagePickerControllerMediaURL] isImage:NO]; 
    }else if([_mediaType isEqualToString:(NSString *)kUTTypeImage]) { 
     [self fileName:[info objectForKey:UIImagePickerControllerOriginalImage] isImage:YES]; 
    } 

    [self dismissViewControllerAnimated:NO completion:^{ 
     [self showFileNameView]; 
    }]; 

} 

_cameraOverlay = nil; 
} 


-(void)openAlbum{ 

    ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus]; 


    if(status != ALAuthorizationStatusAuthorized && status !=ALAuthorizationStatusNotDetermined) 
    { 
    PrivacySetting *setting=[[PrivacySetting alloc]initWithNibName:@"PrivacySetting" bundle:nil]; 
    setting.currentMode=KPhoto; 
    [self.navigationController presentViewController:setting animated:YES completion:nil]; 
} 
else 
{ 

    UIImagePickerController *camPicker = [[UIImagePickerController alloc] init]; 
    camPicker.delegate = (id)self; 

    if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone) { 
     camPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
     [self presentViewController:camPicker animated:YES completion:nil]; 
    } 
    else 
    { 
     popVC = [[UIPopoverController alloc] 
       initWithContentViewController: camPicker]; 
     popVC.delegate = self; 
     fromPopvc=YES; 
     [popVC setPopoverContentSize:CGSizeMake(700,500)]; 

     [self setLocationforPopView]; 
    } 
    } 

} 
-(void)setLocationforPopView{ 
UIInterfaceOrientation curorientation = [[UIApplication sharedApplication] statusBarOrientation]; 
if(curorientation==UIInterfaceOrientationPortrait ||curorientation==UIInterfaceOrientationPortraitUpsideDown) { 
    //Code 
    [popVC presentPopoverFromRect: 
    CGRectMake(self.view.frame.origin.x+self.view.frame.size.width-80,self.view.frame.origin.y+150,0,0) 
          inView:self.view 
     permittedArrowDirections:UIPopoverArrowDirectionUp 
         animated:YES]; 


} 
if (curorientation==UIInterfaceOrientationLandscapeRight ||curorientation==UIInterfaceOrientationLandscapeLeft) { 
    [popVC presentPopoverFromRect: 
    CGRectMake(self.view.frame.origin.x+self.view.frame.size.width-300,self.view.frame.origin.y+160,0,0) 
          inView:self.view 
     permittedArrowDirections:UIPopoverArrowDirectionUp 
         animated:YES]; 
    } 

} 
-(void)fileName:(id)file isImage:(BOOL)isImage 
{ 
f = [[FileNameView alloc] init]; 
[f setMedia:file]; 
f.delegate = self; 
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 
[formatter setDateFormat:@"MM_dd_YYYY"]; 
f.previousFileName = [NSString stringWithFormat:@"%@%@", (isImage) ? @"IMG" : @"VID", [formatter stringFromDate:[NSDate date]]]; 
[f setImage:(isImage) ? file : [PickerHandler generateMovieThumbnail:file]]; 

NSLog(@"file name = %@ isimage =%d",file,isImage); 
} 
+0

, 난 확인하기 위해 UIUserInterfaceIdiomPad로 UIUserInterfaceIdiomPhone을 변경뿐만 아니라 그 일을하지 않은 ... – RaviJSS

답변

0

iPad에없는 경우처럼 평상시에는 UIPopoverController으로 표시하지 마십시오. 예를 들어 :

내가 그것을했을
UIImagePickerController *camPicker = [[UIImagePickerController alloc] init]; 
camPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
camPicker.delegate = self; 
[self presentViewController:camPicker animated:YES completion:nil]; 
+0

하지 아이 패드에서 아이폰에, 실제로 그 작업을 작업하지만? – RaviJSS

+0

@RaviJSS 편집을 참조하십시오. – Michael

+0

죄송합니다 다시는 작동하지 않습니다. – RaviJSS

관련 문제