****更新**得到以下崩溃:[UploadViewController _viewForPresenting]:无法识别的选择器发送到实例0x7abe4c00**
旧的使用 UIPopOvers 的方式在 iOS 8 中被弃用了;所以我尝试升级;不幸的是,它不起作用。我没有得到弹出框本身,只是底部当前视图的顶部(参见此处的图片)。我确定这里缺少一些东西,但是在花了 2 天之后,我没有看到问题。我已经远离编码工作,所以我请求帮助解决这个编码问题。这是我的代码(从这里复制和修改):
// make the popover
UIViewController * popoverContent = [UIViewController new];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 614, 804)];
popoverView.backgroundColor = [UIColor colorWithWhite:(CGFloat)1.0 alpha:(CGFloat)1.0]; // frame color?
popoverContent.view = popoverView;
//resize the popover view shown in the current view to the view's size
popoverContent.preferredContentSize = CGSizeMake(614, 804);
// NSString *urlAddress = @"https://google.com";
NSString *urlAddress = @"http://pragerphoneapps.com/upload-help/";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
// add the UIWebView for RichText
UIWebView *webView = [[UIWebView alloc] initWithFrame: popoverView.frame];
webView.backgroundColor = [UIColor whiteColor]; // change background color here
// add the webView to the popover
[webView loadRequest:requestObj];
[popoverView addSubview:webView];
//create a popover controller
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *controller = [storyboard instantiateViewControllerWithIdentifier:@"UploadViewController"];
// present the controller
controller.modalPresentationStyle = UIModalPresentationPopover;
[self presentViewController: controller animated:YES completion:nil];
// configure the Popover presentation controller
UIPopoverPresentationController *popController = [controller popoverPresentationController];
popController.permittedArrowDirections = UIPopoverArrowDirectionUp;
// get warning on the following line: Incompatible pointer types assigning to 'UIBarButtonItem * _Nullable' from 'UploadViewController *'
popController.barButtonItem = self;
// also get warning on the following line: Assigning to 'id<UIPopoverPresentationControllerDelegate> _Nullable' from incompatible type 'UploadViewController *const __strong'
popController.delegate = self;
popController.sourceView = popoverView;
popController.sourceRect = CGRectMake(10, 10, 614, 804);