我目前正在使用Xcode 6(Beta 6)测试我的应用程序.UIActivityViewController可与iPhone设备和模拟器配合使用,但与iPad模拟器和设备(iOS 8)崩溃并带有以下日志
Terminating app due to uncaught exception 'NSGenericException',
reason: 'UIPopoverPresentationController
(<_UIAlertControllerActionSheetRegularPresentationController: 0x7fc7a874bd90>)
should have a non-nil sourceView or barButtonItem set before the presentation occurs.
Run Code Online (Sandbox Code Playgroud)
我正在为iOS 7和iOS 8使用以下iPhone和iPad代码
NSData *myData = [NSData dataWithContentsOfFile:_filename];
NSArray *activityItems = [NSArray arrayWithObjects:myData, nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:nil applicationActivities:nil];
activityViewController.excludedActivityTypes = @[UIActivityTypeCopyToPasteboard];
[self presentViewController:activityViewController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
我也得到了一个类似的崩溃我的其他应用程序.你能指导我吗?iOS 8中的UIActivityViewController有什么变化吗?我查了但是我没有找到任何关于此的内容
我开始搜索时想知道如何与iOS中的其他应用分享.我发现有两个重要的方法
UIActivityViewControllerUIDocumentInteractionController在这个SO答案中比较了这些和其他方法.
通常当我学习一个新概念时,我希望看到一个让我入门的基本例子.一旦我得到基本的设置,我可以稍后修改它.
有很多与之相关的问题UIActivityViewController,但我找不到任何只是要求一个简单的例子.由于我刚刚学会了如何做到这一点,我将在下面提供我自己的答案.随意添加一个更好的(或Objective-C版本).
在大多数支持iOS 7的iOS应用程序中,我看到了共享选项的这种格式(如下图所示).是否有可用于实现此共享选项的默认代码/框架,如下图所示?

我为我的应用添加了一个共享扩展名,例如SAMPLE(已存在于应用商店中),称为SAMPLESHARE.每当用户说拍照并试图分享它时,我希望他们通过Open In功能的视图控制器,而不是从Apple获得Post对话,基本上绕过它.所以我试图在共享扩展和我的应用程序之间分享图片,创建一个在应用程序和插件之间共享的应用程序组,然后将文件路径传递给我的应用程序的应用程序委托的openURL.
所以在我的主要应用代表中我有
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [[SAMPLEExternalFileHandler shared] handleExternalFileURL:url];
}
Run Code Online (Sandbox Code Playgroud)
如果我有一个需要打开不同流的URL文件路径,我基本上每次都会检查它.
在我的SHAREEXTENSION中,我有
#import "ShareViewController.h"
#import <MobileCoreServices/UTCoreTypes.h>
//Macro to hide post dialog or not, if defined, will be hidden, comment during debugging
#define HIDE_POST_DIALOG
@interface ShareViewController ()
@end
@implementation ShareViewController
NSUInteger m_inputItemCount = 0; // Keeps track of the number of attachments we have opened asynchronously.
NSString * m_invokeArgs = NULL; // A string to be passed to your AIR app with information about …Run Code Online (Sandbox Code Playgroud)