ios - objective-c - Attach UIImage to share -
i have issues following code. thing want image attached share message.
nsstring *texttoshare = @"i'm feeling good!"; nsurl *mywebsite = [nsurl urlwithstring:@"http://www.iamgross.de"]; uiimage *bestimage = [uiimage imagenamed:@"besticon"]; nsarray *objectstoshare = @[bestimage, texttoshare, mywebsite]; dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{ //here non-main thread. uiactivityviewcontroller *activityvc = [[uiactivityviewcontroller alloc] initwithactivityitems:objectstoshare applicationactivities:nil]; nsarray *excludeactivities = @[uiactivitytypeairdrop, uiactivitytypeprint, uiactivitytypeassigntocontact, uiactivitytypesavetocameraroll, uiactivitytypeaddtoreadinglist, uiactivitytypeposttoflickr, uiactivitytypeposttovimeo]; activityvc.excludedactivitytypes = excludeactivities; dispatch_async(dispatch_get_main_queue(), ^{ //here returns main thread. [loading alertisdismissed:^{ [self presentviewcontroller:activityvc animated:yes completion:nil]; }]; }); });
- (void)sharetext:(nsstring *)text andimage:(uiimage *)image andurl:(nsurl *)url { nsmutablearray *sharingitems = [nsmutablearray new]; if (text) { [sharingitems addobject:text]; } if (image) { [sharingitems addobject:itemimage]; } if (url) { [sharingitems addobject:url]; } uiactivityviewcontroller *activitycontroller = [[uiactivityviewcontroller alloc] initwithactivityitems:sharingitems applicationactivities:nil]; [activitycontroller setvalue:@"look @ found" forkey:@"subject"]; [self presentviewcontroller:activitycontroller animated:yes completion:nil]; }
Comments
Post a Comment