1

when I use UIActivityViewController to share video, the ActivityView display facebook ins Twitter Tumblr etc but there is not youtube so I want to write a custom UIActivity for sharing video in youtube But I my English is too poor to understand YouTube API Documentation 。。。


here is my code

import

    @interface RFCustomYoutubeActivity : UIActivity

    @end

    #import "RFCustomYoutubeActivity.h"
    @interface RFCustomYoutubeActivity ()
    @property (nonatomic,strong)NSArray *activityItems;
    @end

@implementation RFCustomYoutubeActivity
+ (UIActivityCategory)activityCategory {
    return UIActivityCategoryShare;
}

- (NSString *)activityType{
    NSString *bundeID = [NSBundle mainBundle].bundleIdentifier;
    NSString *typeStr =[bundeID stringByAppendingString:NSStringFromClass([RFCustomYoutubeActivity class])];
    return typeStr;
}

- (NSString *)activityTitle {
    return @"Youtube"; 
}

- (UIImage *)activityImage {
    return [UIImage imageNamed:@"youtube.png"];
}

- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems{
    for (NSObject *obj in activityItems) {
        if ([obj isKindOfClass:[NSURL class]] ) {
            return YES;
        }
    }
    return NO;
}

- (void)prepareWithActivityItems:(NSArray *)activityItems{
    NSMutableArray *mutableArray=[NSMutableArray array];
    for (NSObject *obj in activityItems) {
        if ([obj isKindOfClass:[NSURL class]]) {
            [mutableArray addObject:obj];
        }
    }
    self.activityItems=[NSArray arrayWithArray:mutableArray];
}

- (void)performActivity{
   //self.activityItems[0] is a video urlPath. 
   //here  i don't konw how to open youtube(app) or share video to youtube 
   //or how to open youtube album  

}

- (void)activityDidFinish:(BOOL)completed{
    NSLog(@"end");
}
riceFun
  • 11
  • 2

0 Answers0