2011-11-21 2 views
1

iPad 응용 프로그램 개발에 익숙하지 않습니다.사용자가 손으로 그림 그리기를 허용하는 응용 프로그램을 만드는 방법은 무엇입니까?

나는 응용 프로그램을 시작하는 방법을 모른다는 iDesk 응용 프로그램과 같은 응용 프로그램을 개발할 작업이 있습니다.

이 응용 프로그램은 1. 자유형 도면 2. 모양 인식 & 훨씬 더 많은 기능. 하지만 난이 응용 프로그램으로 시작하는 방법을 모르겠다. 도와주세요.

이 앱을 만드는 방법에 대한 세부 정보를 제공합니다. 나는이 응용 프로그램이 OpenGL에서 만들어 졌다고 생각한다. 가능한 경우 샘플을 제공해주세요.

도와주세요.

나는 New Question for this topic

이 좀 도와주십시오 주제에 대해 새로운 질문을 게시했다.

+6

어머, 귀하의 앱 작성 방법을 알려주시겠습니까? 가서 튜토리얼을보세요. 앱 개발에 대해 자세히 알아보십시오. 시작하는 법을 모르는 경우, 그 일을하기에 충분하지 않은 좋은 징조입니다. – CommunistPancake

+0

http://stackoverflow.com/questions/how-to-ask – Krishnabhadra

+0

가능한 [iOS 오픈 소스 그리기 응용 프로그램 소스 코드] 중복 (http://stackoverflow.com/questions/4121184/ios-open-source-drawing- application-source-code) –

답변

1

은 내가 이전에 그것을 사용하고 다음을 사용합니다. 확실히 작동 할 것입니다 : -

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

    mouseSwiped = NO; 
    UITouch *touch = [touches anyObject]; 

    if ([touch tapCount] == 2) { 
     [drawImage setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"white" ofType:@"png"]]]; 
     return; 
    } 

    lastPoint = [touch locationInView:self.view]; 
    lastPoint.y -= 20; 

} 

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

    UITouch *touch = [touches anyObject]; 
    CGPoint currentPoint = [touch locationInView:self.drawImage]; 
    currentPoint.y -= 20; 

    NSLog(@"current Point is x: %d, y: %d",currentPoint.x,currentPoint.y); 

    UIGraphicsBeginImageContext(self.drawImage.frame.size); 
    [drawImage.image drawInRect:CGRectMake(0, 0, self.drawImage.frame.size.width, self.drawImage.frame.size.height)]; 
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); 
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0); 
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.5, 0.6, 1.0); 
    CGContextBeginPath(UIGraphicsGetCurrentContext()); 
    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); 
    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y); 
    CGContextStrokePath(UIGraphicsGetCurrentContext()); 
    drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 

    lastPoint = currentPoint; 

} 
4

다음은 드로잉에 사용하는 UIView 하위 클래스입니다. 내가 그것을 공급 곳에 사람이 코드를 인식하면 원래 프로그래머에게 신용을주지하시기 바랍니다 그래서 나는 기억할 수 :

#import <UIKit/UIKit.h> 
#import <QuartzCore/QuartzCore.h> 



@interface SignatureView : UIView { 
     UIImage *myPic; 
    } 

    @property (strong, nonatomic) NSMutableArray *myDrawing; 
    @property (nonatomic) BOOL canDraw; 

    - (void) drawPic:(UIImage*)thisPic; 
    - (void) cancelDrawing; 
    - (UIImage*) collectSignature; 

    @end 




    #import "SignatureView.h" 

    @implementation SignatureView 

    @synthesize canDraw, myDrawing; 

    - (void)drawRect:(CGRect)rect 
    { 
    //round the corners 
    self.layer.cornerRadius = 5; 
    self.clipsToBounds = YES; 

    float newHeight; 
    float newWidth; 
    if (!myDrawing) 
     myDrawing = [[NSMutableArray alloc] initWithCapacity:0]; 

    CGContextRef ctx = UIGraphicsGetCurrentContext(); 
    if (myPic != NULL) 
    { 
     float ratio = myPic.size.height/460; 
     if (myPic.size.width/320 > ratio) 
     { 
      ratio = myPic.size.width/320; 
     } 
     newHeight = myPic.size.height/ratio; 
     newWidth = myPic.size.width/ratio; 
     [myPic drawInRect:CGRectMake(0,0, newWidth, newHeight)]; 
    } 
    if ([myDrawing count] > 0) 
    { 
     CGContextSetLineWidth(ctx, 5); 
     for (int i = 0; i < [myDrawing count]; i++) 
     { 
      NSArray *thisArray = [myDrawing objectAtIndex:i]; 
      if ([thisArray count] > 2) 
      { 
       float thisX = [[thisArray objectAtIndex:0] floatValue]; 
       float thisY = [[thisArray objectAtIndex:1] floatValue]; 
       CGContextBeginPath(ctx); 
       CGContextMoveToPoint(ctx, thisX, thisY); 
       for (int j = 2; j < [thisArray count] ; j+=2) 
       { 
        thisX = [[thisArray objectAtIndex:j] floatValue]; 
        thisY = [[thisArray objectAtIndex:j+1] floatValue]; 
        CGContextAddLineToPoint(ctx, thisX,thisY); 
       } 
       CGContextStrokePath(ctx); 
      } 
     } 
    } 
} 

- (void)drawPic:(UIImage *)thisPic 
{ 
    myPic = thisPic; 
    [self setNeedsDisplay]; 
} 

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    [myDrawing addObject:[[NSMutableArray alloc] initWithCapacity:4]]; //memory leak 
    CGPoint curPoint = [[touches anyObject] locationInView:self]; 
    [[myDrawing lastObject] addObject:[NSNumber numberWithFloat:curPoint.x]]; //memory leak 
    [[myDrawing lastObject] addObject:[NSNumber numberWithFloat:curPoint.y]]; //memory leak 
} 
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    CGPoint curPoint = [[touches anyObject] locationInView:self]; 
    [[myDrawing lastObject] addObject:[NSNumber numberWithFloat:curPoint.x]]; //memory leak 
    [[myDrawing lastObject] addObject:[NSNumber numberWithFloat:curPoint.y]]; //memory leak 
    [self setNeedsDisplay]; 
} 
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    CGPoint curPoint = [[touches anyObject] locationInView:self]; 
    [[myDrawing lastObject] addObject:[NSNumber numberWithFloat:curPoint.x]]; 
    [[myDrawing lastObject] addObject:[NSNumber numberWithFloat:curPoint.y]]; 
    [self setNeedsDisplay]; 
} 

-(void)cancelDrawing 
{ 
    [myDrawing removeAllObjects]; 
    [self setNeedsDisplay]; 
} 

- (UIImage *)collectSignature 
{ 
    //take screenshot 
    UIGraphicsBeginImageContext(self.bounds.size); 
    [self.layer renderInContext:UIGraphicsGetCurrentContext()]; 
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    return viewImage; 
} 

@end 
+0

대단히 고마워 ..이게 내게 많은 도움이되었다 .. :-) – ArunaFromLK

+0

다행히 @ArunaLakmal :) – bennythemink

관련 문제