iOS Question takescreenshot method

Discussion in 'iOS Questions' started by le_toubib, Jul 7, 2015.

  1. le_toubib

    le_toubib Active Member Licensed User

    i m trying to take a screenshot using theis code :
    Code:
    Dim no As NativeObject = Me
       
    Dim bmp As Bitmap = no.RunMethod("TakeScreenshot"Null)
       
    Log(bmp)
       ImageView1.Bitmap = bmp
    but i get this error :

     
  2. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Hi.
    You can use xcode inline code with below code
    Code:
    if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
        UIGraphicsBeginImageContextWithOptions(self.window.bounds.size, NO, [UIScreen mainScreen].scale);
    else
        UIGraphicsBeginImageContext(self.window.bounds.size);

    [self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *
    image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    NSData * imgData = UIImagePNGRepresentation(
    image);
    if(imgData)
        [imgData writeToFile:@
    "screenshot.png" atomically:YES];
    else
        NSLog(@
    "error while taking screenshot");
     
    le_toubib likes this.
  3. narek adonts

    narek adonts Well-Known Member Licensed User

    I think it should be no.runmethod("takescreenshot", array (null))
     
  4. Erel

    Erel Administrator Staff Member Licensed User

Loading...