1.UIActivityViewController is inherited from Uiviewcontroller, is a feature of VC
A. Initializing Init, initwithactivityitems:applicationactivities
Uiactivityviewcontroller *activity = [[Uiactivityviewcontroller alloc] initwithactivityitems:@[@ "Steve Jobs by waiter Lsaacson"] applicationactivities:nil];
B. Actions to be processed after clicking on an option Completionwithitemshandler (block, >8.0) Completionhandler (block, <8.0)
Activity.completionwithitemshandler = ^ (NSString * __nullable Activitytype, BOOL completed, Nsarray * __nullable ret Urneditems, Nserror * __nullable Activityerror) {NSLog ( @ " hahahhahaha " ); if (completed) {NSLog ( @ " completed " ); else @ " cancel "
C. Remove unwanted action Items excludedactivitytypes
// This property indicates that the button you don't want to display is removed Activity.excludedactivitytypes = @[uiactivitytypeairdrop,uiactivitytypemessage];
D. Display change controller (in the middle column of the shared services, the following column of operational services)
[Self.navigationcontroller presentviewcontroller:activity animated:yes Completion:nil]; /* [Self.navigationcontroller pushviewcontroller:activity animated:yes]; error snapshotting a view that have Not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates. */
2. Custom option Item (Uiactivity subclass)
#import <UIKit/UIKit.h>@interface hglactivity:uiactivity@end
#import "HGLActivity.h"NSString*ConstUiactivitytypehglcustommine =@"Hglcustomactivitymine";@implementationhglactivity//default returns NIL. Subclass may override to return custom activity type which is reported to completion handler-(NSString *) activitytype{returnUiactivitytypehglcustommine;}//default returns NIL. Subclass must override and must return Non-nil value-(NSString *) activitytitle{//Presentation of issues returnNslocalizedstring (@"HGL Custom",@"");}//default returns NIL. Subclass must override and must return Non-nil value-(UIImage *) activityimage{//Icons for displayUIImage *im = [UIImage imagenamed:@"XL"]; returnim;}//can be responded to-(BOOL) Canperformwithactivityitems: (Nsarray *) activityitems{returnYES;}- (void) Preparewithactivityitems: (Nsarray *) activityitems{NSLog (@"Preparewithactivityitems"); //trigger after clicking on the picture//Activityitems of Uiactivityviewcontroller transmission}- (void) performactivity{NSLog (@"performactivity");//departure after calling Preparewithactivityitems}+(uiactivitycategory) activitycategory{//return uiactivitycategoryaction; //the following column of operational services returnUiactivitycategoryshare;//Shared Services in the middle column}@end
* Initialize is Uiactivityviewcontroller the last parameter is an array of
Uiactivityviewcontroller *activity = [[Uiactivityviewcontroller alloc] initwithactivityitems:@[@ "Steve Jobs by waiter Lsaacson", [[NSBundle Mainbundle] Urlforresource:@"hgl29" Withextension:@ "txt"]] applicationactivities:@[[[hglactivity Alloc]init]];
Social sharing of Uiactivityviewcontroller systems