我在Container View中使用UIActivityViewController。我想通过电子邮件,推特和脸谱分享一些文字。虽然最后两个完美无缺,但我遇到了电子邮件的问题。问题是作曲家视图不会通过取消事件或尝试发送它来解散!当ActivityView出现时,我收到以下消息:
Launch Services: Registering unknown app identifier com.apple.mobilemail failed
Launch Services: Unable to find app identifier com.apple.mobilemail
这很奇怪,因为应用程序标识符确实没有问题,我可以使用其他视图控制器中的ActivityViewController(当不在容器视图中时)与电子邮件共享文本。 我的代码如下:
- (void)openBtnTouched {
NSString *alertTitleString = [[[GlobalVariables sharedInstance].alertsArray objectAtIndex:self.selectedIndex]objectForKey:@"alertTitle"];
NSString *alertMsgString = [[[GlobalVariables sharedInstance].alertsArray objectAtIndex:self.selectedIndex]objectForKey:@"alertMessage"];
UIActivityViewController *activity;
activity = [[UIActivityViewController alloc] initWithActivityItems:@[alertTitleString,alertMsgString] applicationActivities:nil];
activity.excludedActivityTypes = @[
UIActivityTypeMessage,
UIActivityTypePostToWeibo,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAssignToContact,UIActivityTypeCopyToPasteboard];
activity.completionHandler = ^(NSString *activityType, BOOL completed){
NSLog(@"Activity Type selected: %@", activityType);
if (completed) {
NSLog(@"Selected activity was performed.");
} else {
if (activityType == NULL) {
NSLog(@"User dismissed the view controller without making a selection.");
} else {
NSLog(@"Activity was not performed.");
}
}
};
[self presentViewController:activity animated:YES completion:NULL];
}
答案 0 :(得分:2)
我不确定您的应用是专为iPhone,iPad还是两者设计,但Apple 非常具体关于如何显示UIActivityViewController
。来自their documentation:
在呈现视图控制器时,必须使用适当的方法为当前设备执行此操作。在iPad上,您必须在弹出窗口中显示视图控制器。在iPhone和iPod touch上,您必须以模态方式呈现它。
如果您以其他方式显示它(即在容器视图控制器中),您可能会遇到这种奇怪的行为。我建议您按照Apple的建议显示活动视图控制器。