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)
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?
You were close. Change this:
into:
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 ownNSString
instance won't work in such cases (anyway the exposedconst
are much better looking and work better with code completion from the IDE).