mar*_*ian 6 objective-c ios uimodalpresentationstyle ios9
我开发了一个显示错误的项目:
不推荐使用'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
Run Code Online (Sandbox Code Playgroud)
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"];
}
}
Run Code Online (Sandbox Code Playgroud)
我无法正确引用UiModalPresentationPopover.有人可以帮我解决这个错误.任何帮助深表感谢.谢谢.
使用 UIModalPresentationPopover
在水平常规环境中,呈现样式,其中内容以弹出视图显示.背景内容变暗,弹出窗口外的水龙头导致弹出窗口被解除.如果您不想使用tap来关闭popover,可以将一个或多个视图分配给关联的UIPopoverPresentationController对象的passthroughViews属性,您可以从popoverPresentationController属性获取该属性.
在水平紧凑的环境中,此选项与UIModalPresentationFullScreen的行为相同.
适用于iOS 8.0及更高版本.
例如
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];
Run Code Online (Sandbox Code Playgroud)
否则使用UIPopoverPresentationController
例如
UIPopoverPresentationController *popController = [self. popoverPresentationController];
popController.permittedArrowDirections = UIPopoverArrowDirectionAny;
popController.barButtonItem = self.leftButton;
popController.delegate = self;
Run Code Online (Sandbox Code Playgroud)
额外的参考
| 归档时间: |
|
| 查看次数: |
10561 次 |
| 最近记录: |