iOS Guides | Samples

MonoTouch.UIKit.UIActivityViewController Class

A standard view controller that connects the application to a number of standard services such as social networks, SMS, etc.

See Also: UIActivityViewController


[MonoTouch.Foundation.Register("UIActivityViewController", true)]
[MonoTouch.ObjCRuntime.Introduced(MonoTouch.ObjCRuntime.PlatformName.iOS, 6, 0, MonoTouch.ObjCRuntime.PlatformArchitecture.None, null)]
[MonoTouch.ObjCRuntime.Unavailable(MonoTouch.ObjCRuntime.PlatformName.TvOS, MonoTouch.ObjCRuntime.PlatformArchitecture.All, null)]
public class UIActivityViewController : UIViewController


The UIActivityViewController allows the application user to easily share data between the current application and services. A number of services such as social networks, email, and SMS are provided by the OS. The application developer can create additional services by implementing custom UIActivitys and UIActivityItemProvider. Custom activities are not available in other applications.

The following example shows how to use the UIActivityViewController. In response to a button press, text from a UITextField is made available to the UIActivityViewController. The text is wrapped in the UIActivityitem and this, in turn, is placed into the activityItems array. The application does not have custom UIActivitys, so the applicationActivities array is specified as null. The UIActivityViewController is allocated and presented modally with UIViewController.PresentViewController, which is appropriate for the iPhone. On the iPad, a UIPopoverController should be used. The image shows the UIActivityViewController during presentation.

C# Example

sendButton.TouchUpInside += (sender, e) => {
	var item = UIActivity.FromObject (textField.Text);
	var activityItems = new NSObject[] { item };
	UIActivity[] applicationActivities = null;
	var activityController = new UIActivityViewController (activityItems, applicationActivities);
	PresentViewController (activityController, true, null);

Related content


Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions:

The members of MonoTouch.UIKit.UIActivityViewController are listed below.

See Also: UIViewController

Public Constructors

Default constructor, initializes a new instance of this class.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes to skip initialization and merely allocate the object.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.
Creates a new UIActivityViewController that supports the specified activityItems and applicationActivities.

Public Properties

ClassHandleIntPtr. The handle for this class.
CompletionHandlerAction<MonoTouch.Foundation.NSString, bool>. The callback executed after the UIActivityViewController is dismissed.
CompletionWithItemsHandlerUIActivityViewControllerCompletion. Gets or sets the completion handler that is run when the view controller is dismissed.
ExcludedActivityTypesNSString[]. List of services that should not be displayed.

Public Methods

Assigns the handler that runs when the activity view is dismissed.