看一下子类继承UIActivity,实现中是否少写了- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems这个方法,这个子类必须实现。
- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems
{
return YES;
}
子类其他实现方法
- (UIActivityType)activityType
{
return @"WechatTimeLineShare";
}
+ (UIActivityCategory)activityCategory
{
// 决定在UIActivityViewController中显示的位置,最上面是AirDrop,中间是Share,下面是Action
return UIActivityCategoryShare; // UIActivityCategoryAction;
}
- (UIImage *)_activityImage
{
return [UIImage imageNamed:@"ActivityIcon"]; // 当self.activityCategory = UIActivityCategoryAction时,系统默认会渲染图片,此时重写为 - (UIImage *)activityImage {} 图片显示会有问题
}
- (NSString *)activityTitle
{
return @"朋友圈";
}
- (void)prepareWithActivityItems:(NSArray *)activityItems
{
}
- (void)performActivity
{
[self activityDidFinish:YES];
}