我开发了一个显示错误的项目:
' 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。有人可以帮我解决这个错误。任何帮助深表感谢。谢谢。
答案 0 :(得分:5)
使用 UIModalPresentationPopover
在水平常规环境中,a 在弹出视图中显示内容的演示文稿样式。 背景内容变暗,并在弹出窗口之外进行点击 要被解雇的人员。如果你不想让水龙头解雇 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;