2015-11-03 47 views
0

我想展示我在ipad橫向模式UIImagePicker ..顯示ImagePicker - iPad的

我按照這個例子:https://github.com/guillermomuntaner/GMImagePicker

但我發現了以下錯誤:

<UIView: 0x7f8c9d158800; frame = (0 0; 1024 768); autoresize = W+H; layer = <CALayer: 0x7f8c9d14f090>>'s window is not equal to <LoginRegisterViewController: 0x7f8c9ac51a70>'s view's window! 

有我的代碼:

 UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
     picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
     picker.delegate = self; 
     picker.modalPresentationStyle = UIModalPresentationPopover; 

     UIPopoverPresentationController *popPC = picker.popoverPresentationController; 
     popPC.permittedArrowDirections = UIPopoverArrowDirectionDown; 
     popPC.sourceView = btnImagemPerfil; 
     popPC.sourceRect = btnImagemPerfil.bounds; 
     NSLog(@"%@", NSStringFromCGRect(btnImagemPerfil.bounds)); 
     [self showViewController:picker sender:sender]; 

,並從btnImagemPerfil.boun日誌DS

{{0, 0}, {141, 141}} 
+0

錯誤消息說你有多個窗口。說明。 – matt

+0

這裏有我的didFinishLauching代碼 'self.window = [[UIWindow alloc] init]; self.loginView = [[LoginViewController alloc] initWithNibName:@「Login」bundle:nil]; [FBLoginView class]; [FBProfilePictureView class]; self.window.rootViewController = self.loginRegisterView; [self irLoginRegister:nil]; [self.window makeKeyAndVisible]; self.window.rootViewController = self.loginRegisterView;' –

+0

該代碼根本沒有意義(請將代碼放入您的_question_中,而不是評論中)。 - 你在使用故事板嗎? – matt

回答

1

更新我的代碼:

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate]; 
    appDelegate.window.rootViewController = self; 

UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
     picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
     picker.delegate = self; 
     picker.modalPresentationStyle = UIModalPresentationPopover; 

     UIPopoverPresentationController *popPC = picker.popoverPresentationController; 
     popPC.permittedArrowDirections = UIPopoverArrowDirectionDown; 
     popPC.sourceView = btnImagemPerfil; 
     popPC.sourceRect = btnImagemPerfil.bounds; 
     NSLog(@"%@", NSStringFromCGRect(btnImagemPerfil.bounds)); 
     [self showViewController:picker sender:sender]; 

它爲我工作