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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:09:20+00:00 2026-06-18T17:09:20+00:00

So I’m still learning this Objective C lark and i’ve hit a stump. All

  • 0

So I’m still learning this Objective C lark and i’ve hit a stump. All I want to do is use the value from Sliderchanged to populate the ‘CGFloat lineWidth =’, Hopefully to have the end result of changing the width of the crumbPath line…

******************EDIT*********************

CrumbPathView.h

#import "CrumbPathView.h"

#import "CrumbPath.h"

#import "FirstViewController.h"


@interface CrumbPathView (FileInternal)
- (CGPathRef)newPathForPoints:(MKMapPoint *)points
                  pointCount:(NSUInteger)pointCount
                    clipRect:(MKMapRect)mapRect
                   zoomScale:(MKZoomScale)zoomScale;



@end

@implementation CrumbPathView


-(IBAction)sliderChanged:(UISlider *)sender
{
NSLog(@"slider value = %f", sender.value);
 }

- (void)drawMapRect:(MKMapRect)mapRect
      zoomScale:(MKZoomScale)zoomScale
      inContext:(CGContextRef)context
{
CrumbPath *crumbs = (CrumbPath *)(self.overlay);



CGFloat lineWidth = 30;



// outset the map rect by the line width so that points just outside
// of the currently drawn rect are included in the generated path.
MKMapRect clipRect = MKMapRectInset(mapRect, -lineWidth, -lineWidth);

[crumbs lockForReading];
CGPathRef path = [self newPathForPoints:crumbs.points
                                pointCount:crumbs.pointCount
                                  clipRect:clipRect
                                 zoomScale:zoomScale];
[crumbs unlockForReading];

if (path != nil)
{
    CGContextAddPath(context, path);
    CGContextSetRGBStrokeColor(context, 0.0f, 0.0f, 1.0f, 0.5f);
    CGContextSetLineJoin(context, kCGLineJoinRound);
    CGContextSetLineCap(context, kCGLineCapRound);
    CGContextSetLineWidth(context, lineWidth);
    CGContextStrokePath(context);
    CGPathRelease(path);
 }
}




@end

@implementation CrumbPathView (FileInternal)




static BOOL lineIntersectsRect(MKMapPoint p0, MKMapPoint p1, MKMapRect r)
{
double minX = MIN(p0.x, p1.x);
double minY = MIN(p0.y, p1.y);
double maxX = MAX(p0.x, p1.x);
double maxY = MAX(p0.y, p1.y);

MKMapRect r2 = MKMapRectMake(minX, minY, maxX - minX, maxY - minY);
return MKMapRectIntersectsRect(r, r2);
}

#define MIN_POINT_DELTA 5.0

- (CGPathRef)newPathForPoints:(MKMapPoint *)points
                  pointCount:(NSUInteger)pointCount
                    clipRect:(MKMapRect)mapRect
                   zoomScale:(MKZoomScale)zoomScale
{
// The fastest way to draw a path in an MKOverlayView is to simplify the
// geometry for the screen by eliding points that are too close together
// and to omit any line segments that do not intersect the clipping rect.  
// While it is possible to just add all the points and let CoreGraphics 
// handle clipping and flatness, it is much faster to do it yourself:
//
if (pointCount < 2)
    return NULL;

CGMutablePathRef path = NULL;

BOOL needsMove = YES;

#define POW2(a) ((a) * (a))

// Calculate the minimum distance between any two points by figuring out
// how many map points correspond to MIN_POINT_DELTA of screen points
// at the current zoomScale.
double minPointDelta = MIN_POINT_DELTA / zoomScale;
double c2 = POW2(minPointDelta);

MKMapPoint point, lastPoint = points[0];
NSUInteger i;
for (i = 1; i < pointCount - 1; i++)
{
    point = points[i];
    double a2b2 = POW2(point.x - lastPoint.x) + POW2(point.y - lastPoint.y);
    if (a2b2 >= c2) {
        if (lineIntersectsRect(point, lastPoint, mapRect))
        {
            if (!path) 
                path = CGPathCreateMutable();
            if (needsMove)
            {
                CGPoint lastCGPoint = [self pointForMapPoint:lastPoint];
                CGPathMoveToPoint(path, NULL, lastCGPoint.x, lastCGPoint.y);
            }
            CGPoint cgPoint = [self pointForMapPoint:point];
            CGPathAddLineToPoint(path, NULL, cgPoint.x, cgPoint.y);
        }
        else
        {
            // discontinuity, lift the pen
            needsMove = YES;
        }
        lastPoint = point;
    }
}

#undef POW2

// If the last line segment intersects the mapRect at all, add it unconditionally
point = points[pointCount - 1];
if (lineIntersectsRect(lastPoint, point, mapRect))
{
    if (!path)
        path = CGPathCreateMutable();
    if (needsMove)
    {
        CGPoint lastCGPoint = [self pointForMapPoint:lastPoint];
        CGPathMoveToPoint(path, NULL, lastCGPoint.x, lastCGPoint.y);
    }
    CGPoint cgPoint = [self pointForMapPoint:point];
    CGPathAddLineToPoint(path, NULL, cgPoint.x, cgPoint.y);
 }

return path;
}

@end

CrumbPathView.h

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

@interface CrumbPathView : MKOverlayView
{
}

- (IBAction)sliderChanged:(id)sender;

@end

I’ve added the rest of the code from the .h & .m …

  • 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-18T17:09:22+00:00Added an answer on June 18, 2026 at 5:09 pm

    I think you are mostly there. Your slider is probably stored in a propery…just check it like you would any other property when you need its value.

    Example:

    -(IBAction)sliderChanged:(UISlider *)sender
    {
        //[self drawMapRect...]
    }
    
    -(void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:CGContextRef)context
    {
         CrumbPath *crumbs = (CrumbPath *)(self.overlay);
         CGFloat lineWidth = self.mySliderControl.value;
         //Do something with lineWidth
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am confused How to use looping for Json response Array in another Array.

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.