覆盖UIActivityViewController的默认行为 [英] Override UIActivityViewController default behaviour

查看:204
本文介绍了覆盖UIActivityViewController的默认行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iPhone上的照片应用中,当您选择邮件共享选项时,照片会动画显示为向上滑动的模态视图控制器。如何修改内置UIActivities的行为?例如,我希望能够设置邮件编辑器的主题字段。

In the Photos app on the iPhone, when you select the Mail sharing option, the photo animates into the modal view controller that slides up. How is it possible to modify the behaviour of the built-in UIActivities? For example, I'd like to be able to set the subject field of the mail composer.

推荐答案

不幸的是,自定义主题 UIActivityViewController 邮件编辑器的字段尚未运行。

Unfortunately, customizing the subject field of the UIActivityViewController mail composer is not working yet.

有关于尝试自定义的文档和报告的错误这里讨论了这个问题:

There is a documented and reported bug regarding trying to customize this discussed here:

iphone - 如何在iOS 6中为UIActivityViewController设置收件人?

如果这样做,根据文档,您将能够自定义这些邮件编辑器字段:

If this were working, according to the documentation, you would be able to customize these mail composer fields:


UIActivityTypeMail
对象将提供的内容发布到新的电子邮件中。当
使用此服务时,您可以提供NSString和UIImage对象以及指向本地文件的
NSURL对象作为活动项的数据。
您还可以指定其内容使用mailto
方案的NSURL对象。

UIActivityTypeMail: The object posts the provided content to a new email message. When using this service, you can provide NSString and UIImage objects and NSURL objects pointing to local files as data for the activity items. You may also specify NSURL objects whose contents use the mailto scheme.

因此使用mailto方案, 工作时,你应该能够自定义这样的字段:

So using the mailto scheme, when it is working, you should be able to customize those fields like this:

    NSString *text = @"My mail text";
    NSURL *recipients = [NSURL URLWithString:@"mailto:foo@bar.com?subject=Here-is-a-Subject"];
    NSArray *activityItems = @[text, recipients];

    UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
    [self presentViewController:activityController animated:YES completion:nil];






如果您正在寻找其他方式来定制 UIActivityViewController 这里有一个很好的示例项目:


If your looking for other ways to customize the UIActivityViewControllerthere is an excellent example project here:

https://github.com/russj/ios6ShareDemo

这篇关于覆盖UIActivityViewController的默认行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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