A sample code snippet to copy a combination of image and text in IOS - UIPasteboard.
NSMutableDictionary *photo = [NSMutableDictionary dictionary];
NSMutableDictionary *text = [NSMutableDictionary dictionary];
UIImage *image1 = [UIImage imageNamed:@"myimage.png"];
NSData* imageData = UIImagePNGRepresentation(image1);
[photo setValue:imageData forKey:(NSString*)kUTTypePNG];
[text setValue:@"Test String" forKey:(NSString *)kUTTypeUTF8PlainText];
[[UIPasteboard generalPasteboard] setItems:[NSArray arrayWithObjects:photo, text, nil]];
No comments:
Post a Comment