Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7945163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:46:42+00:00 2026-06-04T00:46:42+00:00

I am working on a iPad drawing app.. were i have a UIView class

  • 0

I am working on a iPad drawing app.. were i have a UIView class which i imported to UIView Controller. but i am getting errors at [self.view drawPic:image];like error: receiver type for uiview instance message does not declare a method with selector ‘drawPic’.

Please find my full code below:

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

@interface signPage : UIViewController<UIImagePickerControllerDelegate>{ 

    }
@property (retain, nonatomic) IBOutlet UIImageView * myImg;

@end



#import "signPage.h"
#import "DrawView.h"

@implementation signPage
@synthesize myImg;

- (void)viewDidLoad {
    [super viewDidLoad];
}



- (IBAction)clear {
    [self.view cancelDrawing];
}

- (IBAction)saveDrawing {
    UIGraphicsBeginImageContext(self.view.bounds.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *finishedPic = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    UIImageWriteToSavedPhotosAlbum(finishedPic, self, @selector(exitProg:didFinishSavingWithError:contextInfo:), nil);
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {

    [self dismissModalViewControllerAnimated:YES];

    [self.view drawPic:image];

}   

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

    [self dismissModalViewControllerAnimated:YES];


}

-(void)exitProg:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Your picture has been saved" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Ok", nil];
    [alertView show];


}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}




@end

@interface DrawView : UIView {

    UIImage *myPic;
    NSMutableArray *myDrawing;
}



@end


#import "DrawView.h"


@implementation DrawView

-(void)drawPic:(UIImage *)thisPic {

    myPic = thisPic;

    [self setNeedsDisplay];
}

- (void)drawRect:(CGRect)rect {

    float newHeight;
    float newWidth;

    if (!myDrawing) {
        myDrawing = [[NSMutableArray alloc] initWithCapacity:0];
    }
    CGContextRef ctx = UIGraphicsGetCurrentContext();

    if (myPic != NULL) {
        float ratio = myPic.size.height/151;
        if (myPic.size.width/302 > ratio) {
            ratio = myPic.size.width/302;
        }

        newHeight = myPic.size.height/ratio;
        newWidth = myPic.size.width/ratio;

        [myPic drawInRect:CGRectMake(109,552,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) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    [myDrawing addObject:[[NSMutableArray alloc] initWithCapacity:4]];

    CGPoint curPoint = [[touches anyObject] locationInView:self];
    [[myDrawing lastObject] addObject:[NSNumber numberWithFloat:curPoint.x]];
    [[myDrawing lastObject] addObject:[NSNumber numberWithFloat:curPoint.y]];
}

- (void) touchesMoved:(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) 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];

}




@end

Kindly suggest me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:46:43+00:00Added an answer on June 4, 2026 at 12:46 am

    You’ve defined drawPic: only for your DrawView class, which you don’t seem to use anywhere in your UIViewController. If you want the function to be accessible to every UIView class, you should define DrawPic as a category.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an iPad app with a split view controller. I have
I'm working on an ipad app which is meant to have several UIWebView controls
I'm working on an iPad app which has a UISplitView . The root view
I am working on an iPad app. I have a viewcontroller which I want
I am working on a drawing app, with pen touch, on iphone and ipad.
I am working on a iPad ordering web app at the moment which consists
I'm working on a iPad app that is mainly a web view. It is
I am working on an iPad app (which will not be submitted to the
I'm working in an iPad app that has a split view with a navigation
i'm working in ipad application,i have a viewController A which have many subviews viewcontroller

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.