R – imagepicker+navigationController causing problems in iphone

iphoneobjective cuiimagepickercontrollerxcode

how do i do this..i have appliation delegate…in which i added uinavigation controller through code…

here is my code…

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
HomeScreenController  *homeScreenobj=[[HomeScreenController alloc] initWithNibName:@"HomeScreen" bundle:[NSBundle mainBundle]];
navController = [[UINavigationController alloc] initWithRootViewController:homeScreenobj]; 
[homeScreenobj release];  
   [window addSubview:navController.view];

// Override point for customization after app launch    
 [window makeKeyAndVisible];
}

on homescreen i have a tabbar with three buttons here is an image

alt text

i want to take photo from library from imagepickerController…but getting weired issues

it is added to the main window i don't know why

here is an image for this

alt text

why this isn't shown fullscreen…. and also if i put this line

imagePickerController.allowsImageEditing = YES;

it hangs don't know why..here is my code to takePhoto….

-(IBAction)TakePhotoClicked
{
imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.allowsImageEditing = YES;
imagePickerController.delegate = self;
imagePickerController.sourceType = 
UIImagePickerControllerSourceTypePhotoLibrary;
//self.navigationController.navigationBar.hidden=YES;
[self.navigationController pushViewController:imagePickerController animated:NO];
//[imagePickerController release];
}

if i don't put this line to commented
//self.navigationController.navigationBar.hidden=YES;

it shows like this

alt text

where clicking on home button take back to home…

Best Answer

You have to present the UIImagePickerController as a modal view controller. So don't push your controller, but present it as modal:

[self.navigationController presentModalViewController:imagePickerController animated:YES];

You can pop the image picker using -[UINavigationController dismissModalViewControllerAnimated:] to go back to the last view controller on the stack.

Related Topic