容器视图中的UIActivityViewController [英] UIActivityViewController inside a Container View

查看:52
本文介绍了容器视图中的UIActivityViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在容器视图内使用UIActivityViewController.我想通过使用电子邮件,Twitter和Facebook共享一些文本.尽管最后两个可以正常工作,但是我对电子邮件有疑问.问题在于,无论是通过取消事件还是尝试发送事件,作曲者视图都不会消失!当ActivityView出现时,我会收到以下消息:

I use a UIActivityViewController inside a Container View. I want to share some text by using Email, twitter and facebook. While the last two works perfectly i have a problem with Email. The problem is that the composer view doesn't dismisses either by canceling the event nor by trying to send it! When the ActivityView appears i get the following message:

Launch Services: Registering unknown app identifier com.apple.mobilemail failed 
Launch Services: Unable to find app identifier com.apple.mobilemail

这很奇怪,因为应用程序标识符确实没有问题,并且我可以在其他视图控制器中使用ActivityViewController(当不在容器视图中时)与电子邮件共享文本.我的代码如下:

This is strange since there is really no problem with the app identifier and i can share text with email, using ActivityViewController in other view controllers (when not in a container view). My code, below:

- (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];
}

推荐答案

我不确定您的应用程序是为iPhone,iPad还是同时为iPhone和iPad设计的,但是Apple 非常关于如何显示 UIActivityViewController .从其文档:

I'm not sure whether your app is designed for iPhone, iPad, or both, but Apple are very specific about how to display a UIActivityViewController. From their documentation:

展示视图控制器时,必须使用适用于当前设备的适当方法.在iPad上,您必须在弹出窗口中显示视图控制器.在iPhone和iPod touch上,必须以模态显示.

When presenting the view controller, you must do so using the appropriate means for the current device. On iPad, you must present the view controller in a popover. On iPhone and iPod touch, you must present it modally.

如果以其他方式(例如,在容器视图控制器中)显示它,则很可能会遇到这种奇怪的行为.我建议您按照Apple的建议显示活动视图控制器.

If you're displaying it in some other way (i.e, in a container view controller) you may well encounter this sort of weird behavior. I'd recommend you display the activity view controller as recommended by Apple.

这篇关于容器视图中的UIActivityViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆