gpt4 book ai didi

ios - 图标灰色自定义 UIActivityViewController

转载 作者:行者123 更新时间:2023-11-29 12:46:42 29 4
gpt4 key购买 nike

我创建了一个自定义 UIActivityViewController 但是当我加载图标时,我所做的让我看到灰色并且你几乎正确加载,有人发生过吗?你是怎么补救的?

ActivityViewCustomActivity *ca = [[ActivityViewCustomActivity alloc]init];
ca.service = @"avanti";
ca.image = image;
ca.act = @"com.avanti.app";
ActivityViewCustomActivity *fa = [[ActivityViewCustomActivity alloc]init];
fa.service = @"facebook";
fa.image = image;//[UIImage imageNamed:@"icon-facebook.jpg"];
fa.act = @"com.facebook.app";
ActivityViewCustomActivity *tw = [[ActivityViewCustomActivity alloc]init];
tw.service = @"twitter";
tw.image = image;
tw.act = @"com.twitter.app";
UIActivityViewController *activityVC =
[[UIActivityViewController alloc] initWithActivityItems:items
applicationActivities:@[ca,fa,tw]];

activityVC.excludedActivityTypes = @[UIActivityTypePostToTwitter,UIActivityTypePostToFacebook,UIActivityTypeMail,UIActivityTypePostToWeibo, UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeSaveToCameraRoll];


activityVC.completionHandler = ^(NSString *activityType, BOOL completed)
{
if ([activityType isEqualToString:@"com.avanti.app"]) {

NSLog(@" activityType: %@", activityType);
NSLog(@" completed: %i", completed);

NSString *name = [q objectAtIndex:indexPath.row];
UIStoryboard *storyboar = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
ListViewController *list = [storyboar instantiateViewControllerWithIdentifier:@"ListViewController"];
list.ide = ide;
list.canale = name;

[self.navigationController pushViewController:list animated:YES];
}
else if ([activityType isEqualToString:@"com.facebook.app"]){
NSLog(@" activityType: %@", activityType);
NSLog(@" completed: %i", completed);
UIActionSheet *action = [[UIActionSheet alloc]initWithTitle:@"Facebook" delegate:self cancelButtonTitle:@"Annulla" destructiveButtonTitle:@"Vuoi pubblicarlo ?" otherButtonTitles:@"ok", nil];
action.actionSheetStyle = UIActionSheetStyleDefault;

[self actionSheet:action clickedButtonAtIndex:2];

[action showInView:[self.view window]];
}
else if ([activityType isEqualToString:@"com.twitter.app"]){
NSLog(@" activityType: %@", activityType);
NSLog(@" completed: %i", completed);
[self shareTwitter];
}
};

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
NSLog(@"ipad");
}
else
{
[self presentViewController:activityVC animated:YES completion:nil];
}
}

e l'activity è così

- (NSString *)activityType
{
return act;
}

- (NSString *)activityTitle
{
return service;
}

- (UIImage *)activityImage
{

// CGRect rect = CGRectMake(0.0f, 0.0f, 85.0f, 85.0f);
// UIGraphicsBeginImageContext(rect.size);
//
// rect = CGRectInset(rect, 15.0f, 15.0f);
// UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:10.0f];
// [path stroke];
//
// rect = CGRectInset(rect, 0.0f, 10.0f);
// [service drawInRect:rect withFont:[UIFont fontWithName:@"Futura" size:15.0f] lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentCenter];
//
// UIImage *imag = UIGraphicsGetImageFromCurrentImageContext();
//
// UIGraphicsEndImageContext();
// //UIImage *ima = [UIImage imageNamed:@"facebook.jpg"];
// return imag;

UIImage *ima = [UIImage imageNamed:@"Icon_Facebook.png"];
return ima;
// if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
// {
// return [UIImage imageNamed:@"Facebook_43x43"];
// }
// else
// {
// return image;
// }
}

- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems
{
NSLog(@"%s", __FUNCTION__);
for (id obj in activityItems) {
if ([obj isKindOfClass:[NSString class]]) {
return YES;
}
}

return NO;
}

- (void)prepareWithActivityItems:(NSArray *)activityItems
{
NSLog(@"%s",__FUNCTION__);

}

- (UIViewController *)activityViewController
{
NSLog(@"%s",__FUNCTION__);
return nil;
}

- (void)performActivity
{
// This is where you can do anything you want, and is the whole reason for creating a custom
// UIActivity


[self activityDidFinish:YES];
}

+ (UIActivityCategory)activityCategory
{
return UIActivityCategoryShare;
}

截图在这里http://i57.tinypic.com/332vtjo.png

.h 是

#import <UIKit/UIKit.h>

@interface ActivityViewCustomActivity : UIActivity

@property (nonatomic, strong) NSString *service;

@property (nonatomic, strong) UIImage *image;

@property (nonatomic, strong) NSString *act;

- (NSString *)activityType;

- (NSString *)activityTitle;

- (UIImage *)activityImage;

- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems;

- (void)prepareWithActivityItems:(NSArray *)activityItems;

- (UIViewController *)activityViewController;

- (void)performActivity;

+ (UIActivityCategory)activityCategory;

@end

最佳答案

尝试将 _ 添加到您的 activityImage 函数有点像

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

关于ios - 图标灰色自定义 UIActivityViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23514960/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com