Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save raghunath44/07db4a2a6139a174759ba0d0fe48d724 to your computer and use it in GitHub Desktop.
Save raghunath44/07db4a2a6139a174759ba0d0fe48d724 to your computer and use it in GitHub Desktop.
[self openPhotoAlbum];
- (void)openPhotoAlbum
{
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.delegate = self;
controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:controller animated:YES completion:NULL];
}];
}
- (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info
{
NSString * mediaType = info[UIImagePickerControllerMediaType];
NSLog(@"image==>>%@",mediaType);
if([mediaType isEqualToString:(__bridge NSString *)kUTTypeImage])
{
NSLog(@"Image");
JSQPhotoMediaItem *photoItem = [[JSQPhotoMediaItem alloc] initWithImage:[UIImage imageNamed:mediaType]];
JSQMessage *photoMessage = [JSQMessage messageWithSenderId:kJSQDemoAvatarIdSquires
displayName:kJSQDemoAvatarDisplayNameSquires
media:photoItem];
[_messages addObject:photoMessage];
[self dismissViewControllerAnimated:picker completion:nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment