简体   繁体   English

iOS5 Twitter Framework-从相机/相机胶卷中选择图像

[英]iOS5 Twitter Framework - Selecting an image from camera / camera roll

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. 我已经在iOS 5中使用新的Twitter框架创建了一个应用程序,但是我正在努力添加一项功能,以允许用户从相机胶卷/相机拍摄中添加照片。

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? 我已经尝试过弄乱UIImagePickerController了,但是我无法使其正常运行,所以不确定我是否吠叫了错误的树,或者在Twitter框架中是否有用于此目的的设置方法?

Thanks 谢谢

You can access the camera roll with the 您可以使用

UIImagePickerController which is the stock iOS object for this. UIImagePickerController ,它是为此的UIImagePickerController iOS对象。

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. 由于url是资产URL,而不是绝对路径。

You can use the info in this answer display image from URL retrieved from ALAsset in iPhone to access the hires image. 您可以在从iPhone中的ALAsset检索的URL中使用此答案显示图像中的信息来访问招聘图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM