Social sharing of Uiactivityviewcontroller systems

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.