我使用UIDocumentInteractionController
在Instagram上分享照片,我可以打开活动表(我不知道应该给我打电话),但是当我点击{{ 1}}它只是崩溃,消息就是这个,
*** - [UIDocumentInteractionController _openDocumentWithApplication:]:发送到解除分配的实例0x1743762c0的消息
注意,我使用ARC,并且还创建了Open in Instagram
的强大属性。
将保留属性添加到UIDocumentInteractionController
,
UIDocumentInteractionController
这是分享的代码,
@property (nonatomic, retain) UIDocumentInteractionController *docController;
我在一个名为&#34; ShareClass&#34;的班级中这样做。 - (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.");
}
}
}
的哪个子类。
注意,我已经检查了一些相同问题的答案,但它们适用于非ARC,我也尝试将属性设置为强或保留两者。这似乎不起作用。
答案 0 :(得分:1)
最后,我通过自定义类的共享实例对其进行排序,该实例将通过应用程序保留,并且不会释放任何实例。不确定是坏还是好,但就像魅力一样。 ^ _O