iPhone签名捕获 [英] iPhone signature capture

查看:104
本文介绍了iPhone签名捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过有线(USB)连接将iPhone的签名转移到.xls文件中?

Is it possible to transfer a signature from an iPhone into an .xls file via a cable (USB) connection?

推荐答案

所以,这可能不是你想要的,但这就是我捕捉用户绘制的签名(用他们的手指/手写笔)的方式。您的UIImageView将具有绘制的签名。我没有想过如何将签名图像传输到.xls,但是你可以将图像保存到设备的照片库,然后像任何其他图像一样将其导出,然后将其放入.xls(我知道,这是一本手册)处理)。我希望这有帮助。

So, this may not be exactly what you are looking for, but this is how I capture a signature drawn by a user (with their finger/stylus). Your UIImageView will have the drawn signature. I have not thought about how to transfer the signature image to the .xls but you could save the image to the device's photo library then export it like you would any other image, then drop it into the .xls (I know, that's a manual process). I hope this helps.

SignatureViewController.h

SignatureViewController.h

IBOutlet UIImageView *signatureImageView;

//Signature Drawing Items
CGPoint lastPoint;
BOOL mouseSwiped;   
int mouseMoved;

SignatureCaptureViewController.m

SignatureCaptureViewController.m

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {      
    mouseSwiped = NO;
    UITouch *touch = [touches anyObject];

    //Clear Signature on Double Tap
    if ([touch tapCount] == 2) {
        signatureImageView.image = nil;
        return;
    }

    lastPoint = [touch locationInView:signatureImageView];

}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    mouseSwiped = YES;

    UITouch *touch = [touches anyObject];   

    CGPoint currentPoint = [touch locationInView:signatureImageView];

    UIGraphicsBeginImageContext(signatureImageView.frame.size);
    [signatureImageView.image drawInRect:CGRectMake(0, 0, signatureImageView.frame.size.width, signatureImageView.frame.size.height)];
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 2.0);
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 1.0);
    CGContextBeginPath(UIGraphicsGetCurrentContext());
    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
    CGContextStrokePath(UIGraphicsGetCurrentContext());

    signatureImageView.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    lastPoint = currentPoint;
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [touches anyObject];

    //Clear Signature on Double Tap
    if ([touch tapCount] == 2) {
        signatureImageView.image = nil;
        return;
    }

    if(!mouseSwiped) {
        UIGraphicsBeginImageContext(signatureImageView.frame.size);
        [signatureImageView.image drawInRect:CGRectMake(0, 0, signatureImageView.frame.size.width, signatureImageView.frame.size.height)];
        CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
        CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 2.0);
        CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 0.0);
        CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
        CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
        CGContextStrokePath(UIGraphicsGetCurrentContext());
        CGContextFlush(UIGraphicsGetCurrentContext());
        signatureImageView.image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    }
}

这篇关于iPhone签名捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆