如何使用UIActivityViewController与MonoTouch的 [英] how to use UIActivityViewController with MonoTouch

查看:120
本文介绍了如何使用UIActivityViewController与MonoTouch的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图访问 UIActivityViewController 从MonoTouch的用下面的代码:

I am trying to access UIActivityViewController from MonoTouch with the following code:

var textToShare = new NSString("hallo there");
var activityItems = new NSObject[] {textToShare};
var excludedActivityTypes = new NSString[] { new NSString("UIActivityTypePostToWeibo"),       new NSString("UIActivityTypeMessage") };
var activityViewController = new UIActivityViewController(activityItems, null);
activityViewController.ExcludedActivityTypes = excludedActivityTypes;
this.PresentViewController(activityViewController, true, null)



显示iOS的动作片,但指定的活动不被排除。
任何建议的问题是什么?是否有任何MonoTouch的样本呢?

The iOS action sheet is displayed but the specified activities are not excluded. Any suggestions what the problem is? Are there any MonoTouch samples for this?

推荐答案

您接近。改变这样的:

var excludedActivityTypes = new NSString[] { 
    new NSString("UIActivityTypePostToWeibo"),
    new NSString("UIActivityTypeMessage") 
};



into:

var excludedActivityTypes = new NSString[] {
    UIActivityType.PostToWeibo,
    UIActivityType.Message
};



注:常量的名称并不总是等同于它的价值。此外,它是常见的(即使是不好的做法),用于ObjC比较的NSString 指针(不是它们的值)来检测恒定的平等 - 创建自己的的NSString 实例将不会在这样的情况下工作(反正暴露常量要好得多寻找和从IDE代码完成更好的工作)。

Note: The name of the constant is not always identical to it's value. Also it's common (even if bad practice) for ObjC to compare the NSString pointers (not their values) to detect constant equality - creating your own NSString instance won't work in such cases (anyway the exposed const are much better looking and work better with code completion from the IDE).

这篇关于如何使用UIActivityViewController与MonoTouch的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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