ios控制器怎么推出popoverpresentationcontroller
1个回答
展开全部
iPad中使用presentViewController如果不设置popoverPresentationController会崩溃,iPhone貌似是不会的
1、在iOS 8.02 一定要设定popoverPresentationController 不然程式会Crash
UIActivityViewController *avc = ....;
if([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0) {
//如果是UIButton
UIButton *btn = (UIButton *)sender;
avc.popoverPresentationController.sourceView = btn;
avc.popoverPresentationController.sourceRect = btn.bounds;
//如果是BarItem
avc.popoverPresentationController. barButtonItem = sender;
}
[self presentViewController:avc animated:YES completion:nil];
2、UIActivityViewController *activityController =
[[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityController animated:YES completion:nil];
解决办法是 在 presentController 前面加一句 if ([activityViewController respondsToSelector:@selector(popoverPresentationController)]) {
activityViewController.popoverPresentationController.sourceView = self.view;
}
1、在iOS 8.02 一定要设定popoverPresentationController 不然程式会Crash
UIActivityViewController *avc = ....;
if([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0) {
//如果是UIButton
UIButton *btn = (UIButton *)sender;
avc.popoverPresentationController.sourceView = btn;
avc.popoverPresentationController.sourceRect = btn.bounds;
//如果是BarItem
avc.popoverPresentationController. barButtonItem = sender;
}
[self presentViewController:avc animated:YES completion:nil];
2、UIActivityViewController *activityController =
[[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityController animated:YES completion:nil];
解决办法是 在 presentController 前面加一句 if ([activityViewController respondsToSelector:@selector(popoverPresentationController)]) {
activityViewController.popoverPresentationController.sourceView = self.view;
}
大雅新科技有限公司
2024-11-19 广告
2024-11-19 广告
这方面更多更全面的信息其实可以找下大雅新。深圳市大雅新科技有限公司从事KVM延长器,DVI延长器,USB延长器,键盘鼠标延长器,双绞线视频传输器,VGA视频双绞线传输器,VGA延长器,VGA视频延长器,DVI KVM 切换器等,优质供应商,...
点击进入详情页
本回答由大雅新科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询