简体   繁体   English

从uiimagepicker在uiwebview中上传图像

[英]uploading image in uiwebview from uiimagepicker

I ran into a bit of a pickle. 我碰到泡菜了。 I am using a uiwebview to load pages of our website through to our app and I am stuck on an upload picture component (embedded in the webpage). 我正在使用uiwebview将我们的网站页面加载到我们的应用程序,并且卡在了上载图片组件(嵌入在网页中)上。

I initially was having issues with the uiwebview being dismissed when choosing/selecting the phone's option to upload a picture. 选择/选择手机上载图片的选项时,我最初遇到的问题是uiwebview被关闭。 However thanks to this post post , the picture gallery now appears and I can select pictures. 但是由于这个帖子 ,该图片库现在看来,我可以选择照片。

I Implemented 我实施了

` `

-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
{
    if ( self.presentedViewController)
    {
        if (flag == YES){
            [super dismissViewControllerAnimated:NO completion:nil];}
    }

` `

instead of the suggested 而不是建议
` `

-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
{
    if ( self.presentedViewController)
    {
        [super dismissViewControllerAnimated:flag completion:completion];
    }
} 

` `
to get it to work though. 使它工作。

Now, the same problem still remains once I do select a picture and press the 'done' button from the gallery. 现在,一旦选择图片并按图库中的“完成”按钮,仍然存在相同的问题。 This closes my UIwebview in the process. 这将在此过程中关闭我的UIwebview。 Is there another method I should be overriding in my uinavigationcontrollers? 我应该在uinavigationcontrollers中重写另一种方法吗?

Try this 尝试这个

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info    
{
    NSURL *urlPath = [info valueForKey:UIImagePickerControllerReferenceURL];
    UIImage *cameraImage = [info valueForKey:UIImagePickerControllerOriginalImage];
    NSData *myData = UIImagePNGRepresentation(cameraImage);
    [self.webview loadData:myData MIMEType:@"image/png" textEncodingName:nil baseURL:nil];
    [self.picker dismissViewControllerAnimated:YES completion:nil];
 }

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

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