iPhone签名捕捉

4

通过USB连接,将iPhone上的签名转移到.xls文件中是否可能?


一个应用程序的签名,例如签收货物的客户签名。 - Stephen Helling
你是在寻找一种捕捉签名的方法,还是只是通过标准附件端口/USB将其从您的应用程序导出到Excel的方法? - JWD
我只能找到通过网络(无线)传输签名的应用程序,而我想将签名导入到笔记本电脑上的xls文件中。 - Stephen Helling
1个回答

7
所以,这可能不是你要找的完全内容,但这就是我如何捕捉用户(用手指/触控笔)绘制的签名。您的UIImageView将拥有绘制的签名。我没有考虑如何将签名图像传输到.xls文件,但您可以将图像保存到设备的照片库中,然后像导出任何其他图像一样导出它,然后将其放入.xls文件中(我知道,这是一个手动过程)。希望这可以帮助您。
SignatureViewController.h
IBOutlet UIImageView *signatureImageView;

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

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

这看起来很不错。我想看看完整的.h文件,并了解更多如何通过界面构建器进行实际集成的内容。 - radven

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接