我有一个UIActivityViewController,我在iPad上的popover中呈现(使用UIPopoverPresentationController)。
最初显示弹出框时,其大小正确。当我点击“更多”时,会有一个“活动”'视图呈现。当我点击“完成”时,UIActivityViewController没有调整到其初始大小,并且UIActivityViewController中的内容很遗憾不会占用整个视图。
以下是采取的步骤:
popover会扩展,以防止文本被截断。
点击“完成”' navigationBar上的按钮:
popover不会再次调整其初始大小。
创建和显示UIActivityViewController的代码:
- (void)actionButtonTapped:(id)sender {
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[self.pdfSummary] applicationActivities:nil];
BOOL canSendMail = [MFMailComposeViewController canSendMail];
NSMutableArray *excluded = [@[UIActivityTypeAddToReadingList,
UIActivityTypeAssignToContact,
UIActivityTypeCopyToPasteboard,
UIActivityTypeMessage,
UIActivityTypePostToFacebook,
UIActivityTypePostToFlickr,
UIActivityTypePostToTencentWeibo,
UIActivityTypePostToTwitter,
UIActivityTypePostToVimeo,
UIActivityTypePostToWeibo,
UIActivityTypeSaveToCameraRoll] mutableCopy];
if (!canSendMail) {
[excluded addObject:UIActivityTypeMail];
}
activityViewController.excludedActivityTypes = excluded;
[self showActivityViewController:activityViewController fromBarButtonItem:sender];
}
showActivityViewController方法看起来像:
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:activityViewController];
navController.modalPresentationStyle = UIModalPresentationPopover;
navController.navigationBarHidden = YES;
UIPopoverPresentationController *popoverPresentationController = [navController popoverPresentationController];
popoverPresentationController.permittedArrowDirections = arrowDirection;
popoverPresentationController.barButtonItem = buttonItem;
[self presentViewController:navController animated:YES completion:nil];
return popoverPresentationController;
是否有任何解决方法。调整popover大小或只保持一个大小?
我尝试过继承UIActivityViewController并更改preferredContentSize,但是UIActivityController的内容不会调整大小以适应popover的大小
答案 0 :(得分:0)
不要将活动控制器放入导航控制器。直接使用活动控制器中的弹出窗口。
您可以按如下方式更新showActivityViewController
:
UIPopoverPresentationController *popoverPresentationController = [activityViewController popoverPresentationController];
popoverPresentationController.permittedArrowDirections = arrowDirection;
popoverPresentationController.barButtonItem = buttonItem;
[self presentViewController:activityViewController animated:YES completion:nil];