Recherche…


AirDrop

Objectif c

Airdrop peut être utilisé à partir de UIActivityViewController . La classe UIActivityViewController est un contrôleur d'affichage standard qui fournit plusieurs services standard, tels que la copie d'éléments dans le presse-papiers, le partage de contenu sur des sites de médias sociaux, l'envoi d'éléments via Messages, AirDrop et certaines applications tierces.

Dans ce cas, nous UIActivityViewController une image via UIActivityViewController

UIImage *hatImage = [UIImage imageNamed:@"logo.png"];
if (hatImage)//checks if the image file is not nil
{
//Initialise a UIActivityViewController
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[hatImage] applicationActivities:nil];
//Excludes following options from the UIActivityViewController menu
NSArray *excludeActivities = @[UIActivityTypePostToWeibo,UIActivityTypePrint, UIActivityTypeMail,UIActivityTypeMessage,UIActivityTypePostToTwitter,UIActivityTypePostToFacebook,
                                                              UIActivityTypeCopyToPasteboard,UIActivityTypeAssignToContact,
                                                              UIActivityTypeSaveToCameraRoll,UIActivityTypeAddToReadingList,
                                                              UIActivityTypePostToFlickr,UIActivityTypePostToVimeo,
                                                              UIActivityTypePostToTencentWeibo];
controller.excludedActivityTypes = excludeActivities;
[self presentViewController:controller animated:YES completion:nil];
}

Rapide

if ((newImage) != nil)
        {
            let activityVC = UIActivityViewController(activityItems: [newImage], applicationActivities: nil)
            activityVC.excludedActivityTypes =[UIActivityTypeAddToReadingList]
            self.presentViewController(activityVC, animated: true, completion: nil)
            
        }


Modified text is an extract of the original Stack Overflow Documentation
Sous licence CC BY-SA 3.0
Non affilié à Stack Overflow