Primero, cree los archivos. Elegí ActivityViewCustomActivity nombre de la mina
Hacer ActivityViewCustomActivity.h tener este aspecto:
#import <UIKit/UIKit.h>
@interface ActivityViewCustomActivity : UIActivity
@end
Hacer ActivityViewCustomActivity.m aspecto:
#import "ActivityViewCustomActivity.h"
@implementation ActivityViewCustomActivity
- (NSString *)activityType
{
return @"yourappname.Review.App";
}
- (NSString *)activityTitle
{
return @"Review App";
}
- (UIImage *)activityImage
{
// Note: These images need to have a transparent background and I recommend these sizes:
// [email protected] should be 126 px, iPadShare should be 53 px, [email protected] should be 100
// px, and iPhoneShare should be 50 px. I found these sizes to work for what I was making.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
return [UIImage imageNamed:@"iPadShare.png"];
}
else
{
return [UIImage imageNamed:@"iPhoneShare.png"];
}
}
- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems
{
NSLog(@"%s", __FUNCTION__);
return YES;
}
- (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
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=yourappid"]];
[self activityDidFinish:YES];
}
@end
Esto es lo que mi imagen se parecía a: Aquí es el .PSD que hice: - Enlace malicioso eliminado - Y aquí está el original de 250 px .png http://i.imgur.com/pGWVj.png
En su controlador de vista hacer esto:
#import "ActivityViewCustomActivity.h"
Y ahora donde desea mostrar su UIActivityViewController
:
NSString *textItem = @"Check out the yourAppNameHere app: itunes http link to your app here";
UIImage *imageToShare = [UIImage imageNamed:@"anyImage.png"];
NSArray *items = [NSArray arrayWithObjects:textItem,imageToShare,nil];
ActivityViewCustomActivity *aVCA = [[ActivityViewCustomActivity alloc]init];
UIActivityViewController *activityVC =
[[UIActivityViewController alloc] initWithActivityItems:items
applicationActivities:[NSArray arrayWithObject:aVCA]];
activityVC.excludedActivityTypes = @[UIActivityTypePostToWeibo, UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeSaveToCameraRoll];
activityVC.completionHandler = ^(NSString *activityType, BOOL completed)
{
NSLog(@"ActivityType: %@", activityType);
NSLog(@"Completed: %i", completed);
};
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:activityVC];
CGRect rect = [[UIScreen mainScreen] bounds];
[self.popoverController
presentPopoverFromRect:rect inView:self.view
permittedArrowDirections:0
animated:YES];
}
else
{
[self presentViewController:activityVC animated:YES completion:nil];
}
funciona muy bien! Gracias. – OscarTheGrouch
De acuerdo con el manual de Apple para iPhone y iPod touch, las imágenes no deben ser mayores de 43 por 43 puntos (lo que equivale a 86 por 86 píxeles para dispositivos con pantallas Retina).) Para iPad, las imágenes no deben tener más de 55 x 55 puntos (lo que equivale a 110 por 110 píxeles para iPads con pantallas Retina). – voromax
El manual de Apple no funciona para todo. Los tamaños de imagen que seleccioné fueron por ensayo y error, y funcionan perfectamente para lo que necesitaba. – klcjr89