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

  • Home
  • SEARCH
  • 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 8704885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:13:25+00:00 2026-06-13T03:13:25+00:00

My application is able to do some simple figure’s drawing (until I get a

  • 0

My application is able to do some simple figure’s drawing (until I get a more stable code, I am sticking with only one figure) and it’s also able to re-size them. The code I use to create a UIView is the following :

- (void)drawRect:(CGRect)rect
{    
    CGContextRef context = UIGraphicsGetCurrentContext();

    [self setContextFillColor:context];
    [self setContextStrokeColor:context];
    [self setLineWidth:context];

    CGFloat lineThickness = [self lineWidth] ;
    CGFloat halfLineThickess = lineThickness / 2.0f;

    CGContextAddRect(context, CGRectMake(halfLineThickess,halfLineThickess, rect.size.width - lineThickness, rect.size.height - lineThickness));

    CGContextDrawPath(context, kCGPathEOFillStroke);
}

Which gives me, with an input size of (100.0f,100.0f), this:

enter image description here

This figure is inside a “container” UIView which in turn is inside an UIScrollView. My problem with this is when I am re-sizing my figure and I reach sizes of around 1000*1000 (my “container” is 20,000*20,000), I start receiving memory warnings and the application finally gives up. So my questions are:

1) Should I consider putting a maximum size for the UIView?

2) How could I use the instruments to track this kind of problems, and see where the problem is coming (or where is the heavy lifting being done).

3) Should I use some kind of caching like this?

4) Are there some general best practices to consider, when drawing an UIView?

5) Should I consider CALayer, although I need to listen to touches?

The re-sizing of the UIView is based mostly on this.

  • 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-13T03:13:26+00:00Added an answer on June 13, 2026 at 3:13 am

    You should not create a UIView this large. It’s just too big. This kind of problem is what CATiledLayer is designed to address. Basically you’ll need to keep track of bounding boxes for your shapes, and use those bounding boxes to figure out which tiles intersect which shapes. When the system asks for a given tile, then you draw all the shapes that intersect it. For very large and complex shapes, you can further optimize by splitting up the shape, but often this isn’t needed.

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

Sidebar

Related Questions

For my application, I need to be able to get some datas from 0-x
I would like to write an simple application able to retrieve some certain data
My application is storing some data in SQL Table called Transactions. Users are able
I have some simple questions, I have a client-server application and data sent on
I am writing a little application that performs some simple actions on some specific
I need to work on an application able to send a mail with automatic
I'd like to have my application be able to add bookmarks to safari programmatically,
I'm in the process of making a Rails application be able to run on
I'd like my application to be able to monitor how much data (I don't
I am creating a software application that is able to update itself. After 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.