DNESS / cocos2d-iphone

Automatically exported from code.google.com/p/cocos2d-iphone
1 stars 0 forks source link

UIImagePickerController not working on iPhone/iPod Touch #1063

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Call UIImagePickerController from current scene:
2. With a new 0.99.5-rc1 template, insert this into the HelloWorldScene.h:
@interface MenuScene : CCLayer <UIImagePickerControllerDelegate, 
UINavigationControllerDelegate>
{
    UIWindow *window;
    UIImage *newImage;
}
3. And this into the HelloWorldScene.m near the top:
-(void)pickPhoto:(UIImagePickerControllerSourceType)sourceType{

    UIImagePickerController *picker = [[UIImagePickerController alloc]init];
    picker.delegate = self;
    picker.sourceType = sourceType;
    picker.wantsFullScreenLayout = YES;
    [picker presentModalViewController:picker animated:YES];

    [[[CCDirector sharedDirector] openGLView] addSubview:picker.view];

}

-(void)imagePickerController:(UIImagePickerController *)picker
    didFinishPickingMediaWithInfo:(NSDictionary *)info{
    // newImage is a UIImage do not try to use a UIImageView
    newImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    // Dismiss UIImagePickerController and release it
    [picker dismissModalViewControllerAnimated:YES];
    [picker.view removeFromSuperview];
    [picker release];
    // Let's create a sprite now that we have an image
    CCSprite *imageFromPicker = [CCSprite spriteWithCGImage:newImage.CGImage key:@"ImageFromPicker"];

}
4. And finally, call it with this in the -init after label is added:
// add the label as a child to this Layer
[self addChild: label];
[self pickPhoto:UIImagePickerControllerSourceTypePhotoLibrary];

What is the expected output? What do you see instead?
I expect the UIImagePicker to appear in portrait via a modal dialog.
Instead only the navigation bar shows up and you can see the scene behind it. 
(black screen with "hello world" and fps counter). No image picker is visible.

What cocos2d version / SVN revision are you using ?
-develop 0.99.5-rc1

What iPhoneSDK are you using ?
4.1

Debug or Release ?
debug

Does this happens on device ? or on the simulator ? or on both ?
Have not tried simulator but have tried devices: iPhone 1g, iPhone 3g, and 
iPhone 4

Please provide any additional information below.
If you follow the same instructions above, but use a 0.99.4 template, the 
ImagePicker appears correctly with no issues.

Original issue reported on code.google.com by jok...@gmail.com on 14 Dec 2010 at 9:44

GoogleCodeExporter commented 9 years ago
I have confirmed this with the final 0.99.5 release, problem still exists when 
placed into the default iOS template

Original comment by jok...@gmail.com on 21 Dec 2010 at 10:31

GoogleCodeExporter commented 9 years ago
I also tested the simulator- same result. Attached is an example project.
Also see this thread for discussion:
http://www.cocos2d-iphone.org/forum/topic/5734?replies=16#post-67867

Original comment by jok...@gmail.com on 21 Dec 2010 at 10:35

Attachments:

GoogleCodeExporter commented 9 years ago
This issue can be worked around by putting in an extra UIViewController
see the discussion:
http://www.cocos2d-iphone.org/forum/topic/5734?replies=16#post-67867

Original comment by jok...@gmail.com on 29 Dec 2010 at 10:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Another way to work around:

http://www.cocos2d-iphone.org/forum/topic/5734#post-69809

Original comment by ourlap...@gmail.com on 6 Jan 2011 at 11:30