UIImagePickerController screen issue in iOS 8+ for iPhone 4s

223 Views Asked by At

I am working on the universal application. I have implemented image picker and code for it is as bellow.

 isimagepiking=TRUE;
imgPicker = [[UIImagePickerController alloc] init];
imgPicker.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;
NSArray *mediaTypesAllowed = [NSArray arrayWithObject:@"public.image"];
[imgPicker setMediaTypes:mediaTypesAllowed];
imgPicker.delegate = self;
imgPicker.allowsEditing = YES;
imgPicker.wantsFullScreenLayout=true;
if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone)
{
    [self presentViewController:imgPicker animated:YES completion:nil];
}

Bellow code print 480 as size.

 NSLog(@"%f",imgPicker.view.frame.size.height);

This things works fine in iphone 5+ with ios 8.3 and in iphone 4 below ios 7.1, But in iphone 4s for ios 8+ picker doesn't show Choose and Cancel button

Screen with ios 7.1 iphone 4s. iOS 7.1 iPhone 4s screen-- This works fine

Screen With iOS 8.2 iPhone 4s -- Not showing Choose or Cancel button Screen With iOS 8.2 iPhone 4s -- Not working properly

It seems like in iOS 8+ it take the uiscreen size as 4 inch. Can anyone please help me with this.

Thanks in Advance

1

There are 1 best solutions below

2
Sudhin Davis On

I hope Presenting the view is making the problem. Try addSubview

isimagepiking=TRUE;
    imgPicker = [[UIImagePickerController alloc] init];
    imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    NSArray *mediaTypesAllowed = [NSArray arrayWithObject:@"public.image"];
    [imgPicker setMediaTypes:mediaTypesAllowed];
    imgPicker.delegate = self;
    imgPicker.allowsEditing = YES;
    imgPicker.wantsFullScreenLayout=true;

    //  Try Adding imagepicker as a subview
    [self createAnimationsinView:self.view];
    [self.view addSubview:imgPicker.view] ;

If you want a present view controller animation, that can also be done.

// Present view controller Animation

-(void)createAnimationsinView:(UIView*)view{
    CATransition* transition = [CATransition animation];
    transition.duration = 0.5;
    transition.type = kCATransitionMoveIn;
    transition.subtype =kCATransitionFromTop;
    [view.window.layer addAnimation:transition forKey:kCATransition];
}