Search code examples
iosiphoneios8uipopovercontroller

UIPopoverController for iphone in ios8 shows white screen


Using UIPopovercontroller below ios8.0 in iphone working fine with this code. But in ios8 it display white screen.

Code :

pickerController = [[UIViewController alloc] init];
UIView *viewV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 150, 160)];
[viewV setBackgroundColor:[UIColor clearColor]];
popOverController = [[UIPopoverController alloc] initWithContentViewController:pickerController];
popOverController.popoverContentSize = CGSizeMake(150, 160);
[popOverController setDelegate:self];

CGRect ImageBtnFrame = [self.view convertRect:sender.frame fromView:self.view];       
[popOverController presentPopoverFromRect:ImageBtnFrame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

Any alternative for ios8, need suggestion.


Solution

  • Try to use the new iOS 8 API for popovers.

    pickerController = [[UIViewController alloc] init];
    UIView *viewV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 150, 160)];
    [viewV setBackgroundColor:[UIColor clearColor]];
    
    UIPopoverPresentationController *popOverController = pickerController .popoverPresentationController;
    popOverController.popoverContentSize = CGSizeMake(150, 160);
    [popOverController setDelegate:self];
    
    popOverController.sourceView = self.view;
    popOverController.sourceRect = sender.frame;
    popOverController.permittedArrowDirections = UIPopoverArrowDirectionUp;
    
    [self presentViewController:popOverController
                         animated:YES
                       completion:nil];