2015-09-04 3 views
-1

Dans mon application ayant l'option de partage, je veux ouvrir cette option de partage dans Actionsheet. comment réaliser cette fonctionnalité?Comment définir imageview dans UIActionSheet dans iOS

NSArray * itemsArray = @[@"www.google.com", @"Google", @"5.png"]; // Anything you want to share 
NSArray * applicationActivities = nil; 

UIActivityViewController * activityViewController = [[UIActivityViewController alloc] initWithActivityItems:itemsArray applicationActivities:applicationActivities]; 

if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) 
{ 
    activityViewController.popoverPresentationController.sourceView = self.view; 
} 
[self presentViewController:activityViewController animated:YES completion:nil]; 

je veux attribuer ma propre image personnalisée, lien et texte alors comment y parvenir

enter image description here

+0

s'il vous plaît poster vos efforts – iAnurag

+0

s'il vous plaît vérifier mon image téléchargée –

Répondre

1

Pourquoi utilisez-vous pas un UIActivityViewController à la place? Ainsi, le système peut gérer où partager:

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 


UIImage * image = [UIImage imageNamed:@"yourimage.png"]; 
NSArray * itemsArray = @[image]; // Anything you want to share 


    NSArray * applicationActivities = nil; 

    UIActivityViewController * activityViewController = [[UIActivityViewController alloc] initWithActivityItems:itemsArray applicationActivities:applicationActivities]; 

    activityViewController.excludedActivityTypes = @[ 
                UIActivityTypePostToWeibo, 
                UIActivityTypeAssignToContact, 
                UIActivityTypeAirDrop, 
                UIActivityTypeAddToReadingList 
                // Whatever you want to exclude 
                ]; 

    if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")){ 
     activityViewController.popoverPresentationController.sourceView = self.view; 
    } 

    [self presentViewController:activityViewController animated:YES completion:nil]; 
+0

NSArray * tabEléments = @ [url? url: [NSNull null], titre? titre: [NSNull null], image? image: [NSNull null]]; if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO (@ "8.0")) { activityViewController.popoverPresentationController.sourceView = viewController.view; } [voirController presentViewController: activityViewController animé: YES achèvement: néant]; a reçu une erreur dans cette ligne –

+0

Remplacer 'url',' title' et 'image' pour vos objets. En fait, ajoutez simplement au tableau ce que vous voulez partager. –

+0

je ne peux pas obtenir .... –