【问题标题】:'UIPopoverController' is deprecated: first deprecated in iOS 9.0 [duplicate]'UIPopoverController' 已弃用:在 iOS 9.0 中首次弃用 [重复]
【发布时间】:2016-01-25 07:23:29
【问题描述】:

我开发了一个显示错误的项目:

'UIPopoverController' 已弃用:首先在 iOS 9.0 中弃用 - UIPopoverController 已弃用。弹出框现在实现为 UIViewController 演示文稿。使用 UIModalPresentationPopover 和 UIPopoverPresentationController 的模态展示风格。

我的编码是:

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"];
}

}

我无法正确引用 UiModalPresentationPopover。有人可以帮我解决这个错误。任何帮助深表感谢。谢谢。

【问题讨论】:

    标签: ios objective-c ios9 uimodalpresentationstyle


    【解决方案1】:

    使用 UIModalPresentationPopover

    在水平规则的环境中, 内容显示在弹出视图中的演示样式。 背景内容变暗并在弹出框之外点击 要关闭的弹出框。如果您不希望点击关闭 popover,你可以为 passthroughViews 分配一个或多个视图 关联的 UIPopoverPresentationController 对象的属性, 您可以从 popoverPresentationController 属性中获取。

    在水平紧凑的环境中,此选项的行为与 UIModalPresentationFullScreen。

    适用于 iOS 8.0 及更高版本。

    参考UIModalPresentationStyle Reference

    例如

    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];
    

    其他使用 UIPopoverPresentationController

    例如

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

    其他reference

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-31
      • 1970-01-01
      • 2017-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-15
      相关资源
      最近更新 更多