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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:53:00+00:00 2026-05-30T01:53:00+00:00

I have a subclassed UIView (currentMapView) that draws a map of several states using

  • 0

I have a subclassed UIView (currentMapView) that draws a map of several states using a series of CGMutablePaths pulled from an XML file. When the user taps on a state the fill color changes from green to purple. Right now I figure out which state was tapped on the fly using CGPathContainsPoint to report back which path was tapped and I then set the fill color of that path and reload the view using setNeedsDisplay. The problem I have is that I need to re-use currentMapView several times (different groups of states) and I’m not sure how I should go about tracking which paths the user has tapped on so I can color them again when I reload the view from the XML file.

Here’s a step by step example of what I’m doing:

  1. currentMapView loads path data from the XML file and draws a map of the Eastern United States.

  2. User taps Florida, and it turns purple (I call ‘setNeedsDisplay’ on currentMapView after setting the fill color of the Florida path using CGContextSetFillColorWithColor)

  3. User taps North Carolina, and it turns purple (I call ‘setNeedsDisplay’ on currentMapView after setting the fill color of the North Carolina path using CGContextSetFillColorWithColor)

  4. User navigates to another view and I need to draw another group of states in currentMapView (wiping out what it there).

    Everything works fine up to here.

  5. When the user returns to the view from step one and I draw map of the Eastern United States again I need to color in the Florida and North Carolina paths again.

What would be the best way to keep track of the paths the user has touched?

  • 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-05-30T01:53:01+00:00Added an answer on May 30, 2026 at 1:53 am

    The easiest way would be to have a global NSMutableSet variable named statesTouched. Initialize it to an empty set in application:didFinishLaunchingWithOptions:.

    Each time the user taps a state, add the name of the state (or a reference to an object that represents the state) to the set:

    [statesTouched addObject:touchedStateName];
    

    When you load the view with states, loop over the states in the view and check whether each is in the set:

    for (NSString *stateName in viewStateNames) {
        if ([statesTouched member:stateName]) {
            [self setColor:[UIColor purpleColor] forStateName:stateName];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIView that contains a number of CALayer subclasses. I am using
I have a UIView subclass that draws itself when -drawRect: is called. It only
I have a Card class subclassed from UIView and a Deck class from NSObject.
I have a subclassed UIView loaded from a nib, and I cannot get a
I have subclassed UIView and created a NIB that controls the main logic for
I'm a bit lost here. I have a class subclassed from UIView called BalloonGuy.
I have this UIView that I subclassed and implemented my own drawRect method. When
I have subclassed UIView, but I need to prevent the frame from changing, so
In my application, I have a UIViewController with a subclassed UIView (and several other
I have subclassed a UIView that already handles single touches and drags. I want

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.