0

I have created an application using the new Twitter framework in iOS 5, however I am struggling to add a feature to allow my users to add a photograph from the camera roll / take with camera.

Can anyone point me in the right direction? Obviously I know I can use;

[tweetSheet addImage:[UIImage imageNamed:@"myImage.png"]];

to add an image, but that is direct from the bundle as opposed to bringing up the devices camera roll. I have tried messing around with UIImagePickerController but I cant get it functioning so not sure if I am barking up the wrong tree or if there is a set method in the Twitter framework for this?

Thanks

Paul Morris
  • 1,763
  • 10
  • 33
  • 47

1 Answers1

1

You can access the camera roll with the

UIImagePickerController which is the stock iOS object for this.

Then when you implement the delegate method

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSLog(@"picker info - %@",info);
    [self dismissPopoverAnimated:YES];
    NSURL *url = [info objectForKey:UIImagePickerControllerReferenceURL];
    //do something with the URL
}

As the url is an asset URL rather than an absolute path.

You can use the info in this answer display image from URL retrieved from ALAsset in iPhone to access the hires image.

Community
  • 1
  • 1
Warren Burton
  • 17,451
  • 3
  • 53
  • 73
  • 1
    Hi, thanks for that. I have managed to access to camera roll and select an image. Having trouble to get it to attach it to a Tweet Sheet. im trying to assign the image to a UIImageView then say [tweetSheet addImage:imageView.image]; – Paul Morris Nov 01 '11 at 21:17