简体   繁体   中英

How do I get image selected by UIImagePicker in UIWebView on certain file input field in iOS?

I am displaying html file in UIWebView which contains file input field. When I click on file input field, it opens default UIImagePicker. So I need image selected by that UIIMagePicker in iOS.

Please help me. Thanks

try to use this webview delegate method.i hope so it will help you.

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
  {

       //write your image picker code.
    }

You can load image from photolibrary to webview as shown in below

 - (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];
   }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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