2013-09-22 94 views
0

編輯 - 我這解決了我自己 - 看筆記底部視圖控制器沒有出現

當Xcode中5使用iOS7,我使用的選項從相機拍攝的圖像,或者從照片庫,一旦圖像被選擇(或拍攝新照片),視圖應該翻轉到下一個屏幕。

這不會發生在運行iOS7的iPhone上,它可以在iPad上正常工作,但方法稍有不同,但它似乎是iOS7上iPhone的唯一問題。

這裏是使用的代碼,例如,從庫函數中選擇圖像;

-(void) choosePic { 
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) { 
     UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init]; 
     cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
     cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeSavedPhotosAlbum]; 
     cameraUI.allowsEditing = NO; 
     cameraUI.delegate = self; 

     if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
     { 
      _popover = [[UIPopoverController alloc] initWithContentViewController:cameraUI]; 
      [_popover presentPopoverFromRect:btnLibrary.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 


     } 
     else 

      [self presentModalViewController: cameraUI animated: YES]; 

    }  
} 

此外,代碼一次選擇器完成;

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

    [[UIApplication sharedApplication] setStatusBarHidden:YES]; 

    [self disableButtons]; 

    //Get image 
    self.originalImage = (UIImage *) [info objectForKey: UIImagePickerControllerOriginalImage]; 

    //Dismiss 
    if(_popover) 
    { 
     if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
     { 
      [_popover dismissPopoverAnimated:YES]; 
      _popover = nil; 
     } 
    } 
    else 
     [picker dismissModalViewControllerAnimated: YES]; 

    //Next 
    [self performSelector: @selector(nextScreen) withObject:nil afterDelay:0.5]; 
} 

我通過切換來解決這個問題;

[picker dismissModalViewControllerAnimated: YES]; 

隨着

[picker dismissViewControllerAnimated:NO completion:nil]; 

回答

0

首先,你需要確保邏輯到達正確的位置,它的目的是,請嘗試將iPhone的特定行之前斷點或NSLog的,試試這個(你也錯過了捲曲牙套,此處添加它們):

-(void) choosePic { 
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) { 
     UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init]; 
     cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
     cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeSavedPhotosAlbum]; 
     cameraUI.allowsEditing = NO; 
     cameraUI.delegate = self; 

     if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
     { 
      _popover = [[UIPopoverController alloc] initWithContentViewController:cameraUI]; 
      [_popover presentPopoverFromRect:btnLibrary.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 


     }else{ 
      NSLog(@"Checkpoint !"); 
      [self presentModalViewController: cameraUI animated: YES]; 
     } 

    }  } 
+0

嘿穆斯塔法,是的,我得到的檢查點在日誌中,出現選擇器,它似乎是一旦圖象被選定後,拾取駁回,則是指翻轉屏幕,但它不,它只是停留在主菜單屏幕沒有翻轉(iOS6和以下工作正常),雖然我確實在控制檯中看到... '2013-09-22 18:14:43.372 [3977:60b]警告:嘗試在上演示正在進行中的!' –

+0

Mostafa,剛剛修復它自己請看我的編輯:) –

+0

哦完美!,很高興它成功了:) –

相關問題