如何通过uiactivityviewcontroller分享不同的网址?

我正在尝试使用UIActivityViewController为每个项目共享不同的URL。 例如,对于twitter:www.google.com; 对于Facebook:www.bing.com

我知道我可以自定义每个文本,但我似乎无法找到一种方法来自定义每个网址。

我试过UIActivityItemProvider的子类,但它没有解决:

文件.m

- (id)initWithText:(NSString *)text{

if ((self = [super initWithPlaceholderItem:text])) {
    self.text = text ?: @"";
    self.url = @"";
}
    return self;
}

- (id)item {
    NSString *activityType = self.activityType;

    if ([self.placeholderItem isKindOfClass:[NSString class]]) {

        if ([self.activityType isEqualToString:UIActivityTypePostToFacebook]) {

            self.url = kSHARELINK_FB;

        } else if ([activityType isEqualToString:UIActivityTypePostToTwitter]) {

            self.url = kSHARELINK_TWITTER;


        } else if ([activityType isEqualToString:UIActivityTypeMessage]) {

            self.url = kSHARELINK_SMS;


            } else if([activityType 

isEqualToString:UIActivityTypeMail]){
            self.url = kSHARELINK_EMAIL;


        }else if ([activityType 

isEqualToString:UIActivityTypePostToWeibo]){
            self.url = kSHARELINK_WEIBO;

        }else{

            self.url = kSHARELINK_OTHER;

        }
    }

    return self.placeholderItem;
}

文件.h

 @interface LLCustomActivityItemProvider : UIActivityItemProvider

@property (copy, nonatomic) NSString *text;
@property (copy, nonatomic) NSString *url;

- (id)initWithText:(NSString *)text;

事实证明,我错过了一个return self.url; ...

- (id)item {
    NSString *activityType = self.activityType;

    if ([self.placeholderItem isKindOfClass:[NSString class]]) {

        if ([self.activityType isEqualToString:UIActivityTypePostToFacebook]) {

            self.url = kSHARELINK_FB;

        } else if ([activityType isEqualToString:UIActivityTypePostToTwitter]) {

            self.url = kSHARELINK_TWITTER;


        } else if ([activityType isEqualToString:UIActivityTypeMessage]) {

            self.url = kSHARELINK_SMS;


            } else if([activityType isEqualToString:UIActivityTypeMail]){
            self.url = kSHARELINK_EMAIL;


        }else if ([activityType isEqualToString:UIActivityTypePostToWeibo]){
            self.url = kSHARELINK_WEIBO;

        }else{

            self.url = kSHARELINK_OTHER;

        }
      return self.url;
    }

    return self.placeholderItem;
}
链接地址: http://www.djcxy.com/p/26827.html

上一篇: how to share different urls via uiactivityviewcontroller?

下一篇: Error in dyn.load() : unable to load shared object