'UIPopoverController' is deprecated: first deprecated in iOS 9.0 [duplicate]
Asked Answered
E

1

6

I have developed a project that shows error :

'UIPopoverController' is deprecated: first deprecated in iOS 9.0 - UIPopoverController is deprecated. Popovers are now implemented as UIViewController presentations. Use a modal presentation style of UIModalPresentationPopover and UIPopoverPresentationController.

My codings are:

ViewController.h:

#import <UIKit/UIKit.h>
#import <Photos/Photos.h>
#import <MobileCoreServices/MobileCoreServices.h>



@interface ViewController : UIViewController
 <UIImagePickerControllerDelegate, UINavigationControllerDelegate>

- (IBAction)touch:(id)sender;

@end

@interface SecondView : UIViewController
<UIImagePickerControllerDelegate, UINavigationControllerDelegate>



//video gallery
@property (strong,nonatomic) UIPopoverPresentationController *popOver;
@property (weak, nonatomic) IBOutlet UIView *studentView;
@property (strong, nonatomic) NSURL *videoURL;


@end

ViewController.m:

- (void)openGallery {

UIImagePickerController *Picker=[[UIImagePickerController alloc] init];
Picker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
Picker.mediaTypes=[[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie,  nil];
Picker.delegate=self;

if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

{


    UIPopoverController *popController=[[UIPopoverController alloc] initWithContentViewController:Picker];
    [popController presentPopoverFromRect:CGRectMake(0, 600, 160, 300) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    self.popOver=popController;
}
else
{
    [self presentViewController:Picker animated:YES completion:nil];
}
}


#pragma mark - UIImagePickerControllerDelegate

 - (void)imagePickerController:(UIImagePickerController *)picker    didFinishPickingMediaWithInfo:(NSDictionary *)info {


if (self.studentView) {

    self.videoURL = info[UIImagePickerControllerMediaURL];
    [picker dismissViewControllerAnimated:YES completion:NULL];


    [[NSUserDefaults standardUserDefaults] setObject:[self.videoURL absoluteString] forKey:@"url1"];
}

}

I could not proper reference for UiModalPresentationPopover. Can someone help me to solve this error. Any help is much appreciated. Thank you.

Este answered 26/10, 2015 at 8:45 Comment(0)
I
5

use UIModalPresentationPopover

In a horizontally regular environment, a presentation style where the content is displayed in a popover view. The background content is dimmed and taps outside the popover cause the popover to be dismissed. If you do not want taps to dismiss the popover, you can assign one or more views to the passthroughViews property of the associated UIPopoverPresentationController object, which you can get from the popoverPresentationController property.

In a horizontally compact environment, this option behaves the same as UIModalPresentationFullScreen.

Available in iOS 8.0 and later.

Reference UIModalPresentationStyle Reference

for example

ModalViewController *modal = [[ModalViewController alloc] init];
modal.modalPresentationStyle = UIModalPresentationPopover;
modal.transitioningDelegate = self;
modal.popoverPresentationController.sourceView = self.view;
modal.popoverPresentationController.sourceRect = CGRectZero;
modal.popoverPresentationController.delegate = self;

[self presentViewController:modal animated:YES completion:nil];

else use UIPopoverPresentationController

for example

UIPopoverPresentationController *popController = [self. popoverPresentationController];
popController.permittedArrowDirections = UIPopoverArrowDirectionAny;
popController.barButtonItem = self.leftButton;
popController.delegate = self;

additional reference

Individuation answered 26/10, 2015 at 9:3 Comment(1)
The above not navigating to the screens while on clicking the labels available insde the popover. [popover presentPopoverFromRect:self.titleView.frame inView:self.navigationController.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];His

© 2022 - 2024 — McMap. All rights reserved.