ios - UIActivityViewController 在 iPad 上不起作用? iOS 8
<p><p>我已遵循类似 SO 问题的建议,但似乎无法完成这项工作。我正在开发一款游戏,它会报告最后的得分,然后是最后得分的分享按钮。</p>
<p>这适用于 iPhone,而我的 iPad 代码如下所示。当我点击分享按钮时,iPad 版本就崩溃了。此代码来自 <a href="http://www.codingexplorer.com/add-sharing-to-your-app-via-uiactivityviewcontroller/" rel="noreferrer noopener nofollow">this tutorial on Coding Explorer</a> .</p>
<p>iPad 代码(不起作用)</p>
<pre><code>- (IBAction)shareButton:(id)sender;
{
NSString * text = ;
NSArray *objectsToShare = @;
UIActivityViewController *activityVC = [ initWithActivityItems:objectsToShare applicationActivities:nil];
NSArray *excludeActivities = @[UIActivityTypeAirDrop,
UIActivityTypePrint,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo];
activityVC.excludedActivityTypes = excludeActivities;
;
}
</code></pre>
<p>iPhone 代码(确实有效)</p>
<pre><code>- (IBAction)ShareIt {
NSString * text = ;
NSArray * activityItems = @;
UIActivityViewController * avc = [ initWithActivityItems:activityItems applicationActivities:nil];
avc.excludedActivityTypes = @[ UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll];
;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您必须添加源 View 。</p>
<p>尝试添加这一行:</p>
<pre><code>activityVC.popoverPresentationController.sourceView = self.view;
</code></pre>
<p>你也可以添加箭头方向:</p>
<pre><code>activityVC.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionRight;
activityVC.popoverPresentationController.sourceView = sender;
</code></pre></p>
<p style="font-size: 20px;">关于ios - UIActivityViewController 在 iPad 上不起作用? iOS 8,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/34404782/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/34404782/
</a>
</p>
页:
[1]