Search code examples
iphoneiosobjective-cuiimagepickercontroller

UIImagePickerController when dismissed pushes view to 20 px up in iOS 6.0 only


EDIT : I am using UIStoryBoard.

I have presented like this:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

imagePicker.delegate = self;

imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; //| UIImagePickerControllerSourceTypeSavedPhotosAlbum ;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage,nil];

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
    {
        imagePicker.allowsEditing = YES;
        [self.navigationController presentViewController:imagePicker animated:YES completion:^{

        }];  
    }
}

Now when dissmissed

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
   UIImage *image = info[UIImagePickerControllerEditedImage];
    NSLog(@"Image : %@",image);
    [self dismissViewControllerAnimated:YES completion:^{
    }];
}

Now view becomes like this as shown in fiqure :

enter image description here

EDIT : view gets pushed up to 20px when dissmissed.

EDIT : This is only in iOS 6.0 only


Solution

  • The reason was i was setting frame of view controller which is in protrait mode as its previous view was in landscape mode.

    self.view.bounds = CGRectMake(0,0,...,...);
    

    Whenever imagepicker dissmiss got called it moved to original position as mentioned.

    Now changed in structure for orientation without setting self.view frame externally solved my problem.