我正在尝试实现一个 UIPopoverController 以便能够共享但是当 UIPopoverController 是视图时显示为空并且我没有任何错误。这是我的代码:
if ([self.activityPopoverController isPopoverVisible]) {
[self.activityPopoverController dismissPopoverAnimated:YES];
} else {
NSString *textToShare=@"I'm sharing this image";
NSArray *activityItems = [[NSArray alloc]initWithObjects:self.imgToSend,textToShare,nil];
UIActivityViewController *activityVC=[[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes=@[UIActivityTypeAssignToContact,UIActivityTypeCopyToPasteboard ];
activityVC.completionHandler = ^(NSString *activityType, BOOL completed){
[self.activityPopoverController dismissPopoverAnimated:YES];
};
if (self.activityPopoverController) {
[self.activityPopoverController setContentViewController:activityVC];
} else {
self.activityPopoverController = [[UIPopoverController alloc] initWithContentViewController:activityVC];
}
[self.activityPopoverController presentPopoverFromRect:[(UIControl *)sender frame]
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
你们中的任何人都可能知道为什么我的代码有问题?
我真的很感谢你的帮助。
更新:
我添加这行代码:
[self.activityPopoverController setPopoverContentSize:self.contentSizeForViewInPopover animated:YES];
但它看起来都被砍掉了: