我使用UIDocumentInteractionController
在Instagram上分享照片,我可以打开操作表(我不知道应该怎么称呼),但是当我点击Open in Instagram
它只是崩溃和消息将是,消息发送到释放实例,同时使用UIDocumentInteractionController的Instagram
*** - [UIDocumentInteractionController _openDocumentWithApplication:]:消息发送到释放实例0x1743762c0
对于一个音符,我使用ARC,和也创造了UIDocumentInteractionController
的强大财产。
新增保有财产UIDocumentInteractionController
,
@property (nonatomic, retain) UIDocumentInteractionController *docController;
这是分享代码,
- (UIDocumentInteractionController *)setupControllerWithURL:(NSURL*)fileURL usingDelegate:(id <UIDocumentInteractionControllerDelegate>) interactionDelegate
{
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
interactionController.delegate = interactionDelegate;
return interactionController;
}
- (void) instagramShare {
NSURL *instagramURL = [NSURL URLWithString:@"instagram://"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
NSString *filePath = [self saveAsIgoFile];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", filePath]];
CGRect rect = CGRectMake(0, 0, 0, 0);
self.docController = [self setupControllerWithURL:igImageHookFile usingDelegate:(id)_view];
self.docController.UTI = @"com.instagram.photo";
self.docController.annotation = [NSDictionary dictionaryWithObject:_titleToShare forKey:@"InstagramCaption"];
[self.docController presentOpenInMenuFromRect:rect inView:_view.parentViewController.view animated:YES];
}
else
{
if(_block) {
_block (_shareType, NO, @"Instagram not installed in this device!\nTo share photo/video please install Instagram application.");
}
}
}
我在一个班,名为 “ShareClass” 的NSObject
其子这样做。
请注意,我已经检查了一些同样问题的答案,但是它们是针对非ARC的,我也尝试将属性设置为强或保留两者。这似乎并不奏效。
'interactionDelegate'在这里如何使用?你正在实现'documentInteractionControllerViewControllerForPreview:controller '委托方法吗? – sleepwalkerfx 2014-12-05 09:04:23
这段代码工作正常,除非我没有在块中使用它自定义类。 – Hemang 2014-12-05 09:05:47
上面的委托方法必须返回您的呈现ViewController。你做得对吗? – sleepwalkerfx 2014-12-05 09:07:07