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 7814413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:11:13+00:00 2026-06-02T05:11:13+00:00

I am trying to draw a rectangle where the user moves the finger on

  • 0

I am trying to draw a rectangle where the user moves the finger on an iPad:

Interface of ViewController:

@interface ViewController : UIViewController {
    NSMutableArray *paths;
}

Implementation:

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

    for (UITouch *touch in touches) {
        CGPoint location = [touch locationInView:self.view];

        CGRect aRectangle = CGRectMake(location.x, location.y, 40, 40);
        UIBezierPath *path = [UIBezierPath bezierPathWithRect:aRectangle];

        path = [UIBezierPath bezierPathWithOvalInRect:aRectangle];

        [paths addObject:path];       
    }
}

- (void)drawRect:(CGRect)rect {
    for (UIBezierPath *path in paths) {
        [path fill];
    }
}

but nothing will draw on screen… I thought maybe I didn’t tell the view to refresh itself and call drawRect, but I tried going to iPad’s home screen and re-enter the app and still nothing show?

(I was going to use an array of points, but since CGPoint is not an object that will stay, so it can’t be added to the mutable array and also it will go away after the local scope ends. How can it be an array of points instead?)

  • 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-02T05:11:14+00:00Added an answer on June 2, 2026 at 5:11 am

    drawRect is a method from UIView but not UIViewController. You gonna need to create your custom UIView subclass and overwrite drawRect in it, and then bind the custom view class to your view in XIB/NIB if you are using Interface Builder to build your UI structure.

    Refer to iPhone: why isn't drawRect getting called?

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

Sidebar

Related Questions

I am trying to draw a rectangle and let the user create it based
I'm trying to allow the user to draw a rectangle on the canvas (like
I am simply trying to draw a rectangle inside of a panel using flex4.
I am trying to just draw a Rectangle on a PictureBox that is on
I am trying to draw a red rectangle on my HTML5 canvas. Here is
I am trying to draw some basic graphics primitives(line, rectangle etc.) using GDI+ apis
I am trying to draw rectangle on top of image and I am having
I'm trying to draw a rectangle on the canvas with the center at the
I am writing an Eclipse RCP-based application and am trying to draw a rectangle
I am trying to draw a rectangle on a windows mobile phone. Draw the

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.