iOS Guides | Samples

MonoTouch.UIKit.UIActivity Class

Abstract base class of activities to which the UIActivityViewController can send data.

See Also: UIActivity

Syntax

[MonoTouch.Foundation.Register("UIActivity", 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 UIActivity : NSObject

See Also

Remarks

The UIActivityViewController can be used to send data to services such as social networks, email, SMS, etc. The operating system provides a number of these, such as UIActivityType.PostToFacebook, UIActivityType.Mail, and UIActivityType.Message.

You can create a new service by subclassing UIActivity and, optionally, UIActivityItemProvider. This service will only be available to your own application; there is no way to make for non-Apple developers to make a UIActivity that is available across apps.

When subclassing, you should override the UIActivity.Image, UIActivity.Title, UIActivity.Type, UIActivity.Prepare and UIActivity.CanPerform.

C# Example

//
// Share an image 
//
var imageToShare = UIImage.FromFile ("demo.png");
var activityItems = new NSObject[] { imageToShare };
var controller = new UIActivityViewController (activityItems, null);
this.PresentViewController(controller, true, null)

// 
// Now share the image, but explicitly exclude posting as a message
//
controller = new UIActivityViewController (activityItems, null) {
    ExcludedActivityTypes = new NSString[] {
        UIActivityType.PostToWeibo,
        UIActivityType.Message
    }
};
this.PresentViewController(controller, true, null)

Related content

Requirements

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

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

See Also: NSObject

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.

Public Properties

[read-only]
static
CategoryUIActivityCategory. The category of the UIActivity, which may be used to group activities in the UI.
[read-only]
override
ClassHandleIntPtr. The handle for this class.
[read-only]
ImageUIImage. An image that identifies the service to the app user.
[read-only]
TitleString. A string describing the service to the app user.
[read-only]
TypeNSString. Identifier for the service provided.
[read-only]
ViewControllerUIViewController. The UIViewController to present to the app user.

Public Methods

CanPerform(NSObject[]) : Boolean
Whether the service can act on the specified data items.
Finished(Boolean)
Notifies the system that this UIActivity has completed its work.
Perform()
Performs the service when no custom UIViewController is provided.
Prepare(NSObject[])
Prepares the service to act on the specified data.