UIActivityViewController Class123
-
Upload
qamar-saleem -
Category
Documents
-
view
216 -
download
0
Transcript of UIActivityViewController Class123
-
8/10/2019 UIActivityViewController Class123
1/9
UIActivityViewController Class Reference
-
8/10/2019 UIActivityViewController Class123
2/9
Contents
UIActivityViewController Class Reference 3
Overview 3
Tasks 3
Initializing the Activity View Controller 3
Accessing the Completion Handler 4
Excluding Specific Activity Types 4
Properties 4
completionHandler 4
excludedActivityTypes 4Instance Methods 5
initWithActivityItems:applicationActivities: 5
Constants 6
UIActivityViewControllerCompletionHandler 6
Document Revision History 8
2013-04-23 | Copyright 2013 Apple Inc. All Rights Reserved.
2
-
8/10/2019 UIActivityViewController Class123
3/9
Inherits from UIViewController : UIResponder : NSObject
Conforms to NSCoding (UIViewController)
UIAppearanceContainer (UIViewController)
NSObject (NSObject)
Framework /System/Library/Frameworks/UIKit.framework
Availability Available in iOS 6.0 and later.
Declared in UIActivityViewController.h
OverviewThe UIActivityViewController class is a standard view controller that you canuseto offer various services
from your application. The systemprovides several standard services, such as copying items to thepasteboard,
posting content to social media sites, sending items via email or SMS, and more. Apps can also define custom
services.
Your app is responsible for configuring, presenting, and dismissing this view controller. Configuration for the
view controller involves specifying the data objects on which the view controller should act. (You can also
specify the list of custom services your app supports.) When presenting the view controller, you must do so
using theappropriate means for the current device. On iPad, youmust present the view controller in a popover.
On iPhone and iPod touch, you must present it modally.
TasksInitializing the Activity View Controller
initWithActivityItems:applicationActivities:(page 5)
Initializes and returns a new activity view controller object that acts on the specified data.
2013-04-23 | Copyright 2013 Apple Inc. All Rights Reserved.
3
UIActivityViewController Class Reference
-
8/10/2019 UIActivityViewController Class123
4/9
Accessing the Completion Handler
completionHandler(page 4) property
The completion handler to execute after the activity view controller is dismissed.
Excluding Specific Activity Types
excludedActivityTypes(page 4) property
The list of services that should not be displayed.
Properties
completionHandler
The completion handler to execute after the activity view controller is dismissed.
@property(nonatomic,copy) UIActivityViewControllerCompletionHandler completionHandler
Discussion
When the user-selected service finishes operating on the data, or when the user dismisses the view controller,
the view controller executes this completion handler to let your app know the final result of the operation.
Availability
Available in iOS 6.0 and later.
Declared in
UIActivityViewController.h
excludedActivityTypes
The list of services that should not be displayed.
UIActivityViewController Class Reference
Properties
2013-04-23 | Copyright 2013 Apple Inc. All Rights Reserved.
4
-
8/10/2019 UIActivityViewController Class123
5/9
@property(nonatomic,copy) NSArray *excludedActivityTypes
Discussion
This property contains an array of strings, each of which corresponds to the value you would find in the
activityTypeparameter of aUIActivityobject. Each string you specify indicates a service that you do
not want displayed to the user. You might exclude services that you feel are not suitable for the content youare providing. For example, you might not want to allow the user to print a specific image. If the value of this
property isnil, no services are excluded.
This value of this property isnilby default.
Availability
Available in iOS 6.0 and later.
Declared in
UIActivityViewController.h
Instance Methods
initWithActivityItems:applicationActivities:
Initializes and returns a new activity view controller object that acts on the specified data.
- (id)initWithActivityItems: (NSArray *)activityItems applicationActivities:(NSArray
*)applicationActivities ;
Parameters
activityItems
The array of data objects on which to perform the activity. The type of objects in the array is variable and
dependent on the data your application manages. For example, the data might consist of one or more
string or image objects representing the currently selected content.
Instead of actual data objects, the objects in this array can be objects that adopt the
UIActivityItemSource protocol, such as UIActivityItemProviderobjects. Source and provider
objects act as proxies for the corresponding data in situations where you do not want to provide that
data until it is needed.
This array must not beniland must contain at least one object.
applicationActivities
An array ofUIActivityobjects representing the custom services that your application supports. This
parameter may benil.
UIActivityViewController Class Reference
Instance Methods
2013-04-23 | Copyright 2013 Apple Inc. All Rights Reserved.
5
-
8/10/2019 UIActivityViewController Class123
6/9
Return Value
The activity view controller to present.
Discussion
It is your responsibility to present and dismiss the view controller using the appropriate means for the givendevice idiom. On iPad, you must present the view controller in a popover. On other devices, you must present
it modally.
Availability
Available in iOS 6.0 and later.
Declared in
UIActivityViewController.h
Constants
UIActivityViewControllerCompletionHandler
A completion handler to execute after the activity view controller is dismissed.
typedef void (^UIActivityViewControllerCompletionHandler)(NSString *activityType, BOOL
completed);
Discussion
Upon the completion of an activity, or the dismissal of the activity view controller, the view controllers
completion block is executed. You can use this block to execute any final code related to the service. The
parameters of this block are as follows:
activityType
The type of the service that was selected by the user. For custom services, this is the value returned by
the activityType method of a UIActivity object. For system-defined activities, it is one of the strings
listed in "Built-in Activity Types inUIActivity Class Reference.
completedYESif the service was performed or NOif it was not. This parameter is also set toNOwhen the user
dismisses the view controller without selecting a service.
Availability
Available in iOS 6.0 and later.
UIActivityViewController Class Reference
Constants
2013-04-23 | Copyright 2013 Apple Inc. All Rights Reserved.
6
-
8/10/2019 UIActivityViewController Class123
7/9
Declared in
UIActivityViewController.h
UIActivityViewController Class Reference
Constants
2013-04-23 | Copyright 2013 Apple Inc. All Rights Reserved.
7
-
8/10/2019 UIActivityViewController Class123
8/9
This table describes the changes toUIActivityViewController Class Reference .
NotesDate
Named the task for the excludedActivityTypes property.2013-04-23
New document that describes how to present app services to the user.2012-09-19
2013-04-23 | Copyright 2013 Apple Inc. All Rights Reserved.
8
Document Revision History
-
8/10/2019 UIActivityViewController Class123
9/9
Apple Inc.
Copyright 2013 Apple Inc.
All rights reserved.
No part of this publication may be reproduced,
storedin a retrievalsystem, or transmitted, in any
form or by any means, mechanical, electronic,photocopying, recording, or otherwise, without
prior written permission of Apple Inc., with the
following exceptions: Any person is herebyauthorized to store documentation on a single
computer for personal use only and to print
copies of documentation for personal useprovided that the documentation contains
Apples copyright notice.
No licenses, express or implied, are granted with
respect to anyof thetechnology describedin this
document. Apple retains all intellectual propertyrights associated with the technology described
in this document. This document is intended to
assist application developers to develop
applications only for Apple-labeled computers.
Apple Inc.1 Infinite Loop
Cupertino, CA 95014
408-996-1010
Apple, the Apple logo, iPad, iPhone, iPod, and
iPod touch are trademarks of Apple Inc.,
registered in the U.S. and other countries.
iOS is a trademark or registered trademark ofCisco in the U.S. and other countries and is used
under license.
Even though Apple has reviewed this document,APPLE MAKES NO WARRANTY OR REPRESENTATION,EITHER EXPRESS OR IMPLIED,WITH RESPECT TO THIS
DOCUMENT, ITS QUALITY, ACCURACY,MERCHANTABILITY, OR FITNESS FOR A PARTICULARPURPOSE. AS A RESULT,THIS DOCUMENT IS PROVIDEDAS IS, AND YOU, THE READER, ARE ASSUMING THEENTIRE RISK AS TO ITS QUALITY AND ACCURACY.
IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT,INDIRECT, SPECIAL,INCIDENTAL,OR CONSEQUENTIALDAMAGES RESULTING FROM ANY DEFECT ORINACCURACY IN THIS DOCUMENT, even if advised ofthe possibility of such damages.
THE WARRANTY AND REMEDIES SET FORTH ABOVEARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORALOR WRITTEN, EXPRESS OR IMPLIED. No Apple dealer,agent, or employee is authorized to make anymodification, extension,or addition to this warranty.
Some states do not allow the exclusion or limitationof implied warranties or liability for incidental orconsequential damages, so the above limitation orexclusion may not apply to you. This warranty givesyou specific legal rights, andyou mayalsohaveother
rights which vary from state to state.