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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:46:01+00:00 2026-06-07T08:46:01+00:00

I suppose I’ll start with the code… – (void) mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {

  • 0

I suppose I’ll start with the code…

- (void) mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
  DLog(@"annotation: %@", [[view annotation] title]);
  self.selectedAnnotation = [view annotation];
 [self.directionsView setHidden:NO];
 [UIView beginAnimations:@"slideup" context:NULL];
 self.directionsView.frame = CGRectOffset(self.directionsView.frame, 0, -self.directionsView.frame.size.height);
 [UIView commitAnimations];
}

I have a map where users can tap on a business and a uiview “directionsView” slides up from the bottom. The problem occurs when more than one business is tapped. The view keeps climbing by 49 pixels. How do I keep this from happening?

I have another method that defines what happens when a business is deselected and I tried using the same animation method, only in reverse (with setHidden:YES), but no luck 🙂

Help pretty please?

  • 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-07T08:46:02+00:00Added an answer on June 7, 2026 at 8:46 am

    Every time this method gets invoked, you’re subtracting from the Y component of the self.directionView’s origin:

    self.directionsView.frame = CGRectOffset(self.directionsView.frame, 0, -self.directionsView.frame.size.height);
    

    So if you tap multiple times without something else resetting the view’s position, it will keep sliding up in its parent view (perhaps off the top of the screen, which I always find entertaining when I accidentally do this).

    The simplest solution is to define two CGRects, and directly assign one or the other to self.directionView.frame based on whether you want the view on- or off-screen. You can call these multiple times in a row, and the effect won’t be cumulative like in your example.

    CGRect onScreen = CGRectMake(x, y, l, w); //Fill in actual values
    CGRect offScreen = CGRectMake(x, larger_value_of_y, l, w); //Again, use actual values
    

    You could also set the frame to its normal “on-screen” value, and adjust the directionView’s transform property, which is also animatable. Again, you can apply either of these multiple times and the effects aren’t cumulative.

    //on screen
    self.directionsView.transform = CGAffineTransformIdentity; //"identity" meaning no change to position
    //off screen
    self.directionsView.transform = CGAffineTransformMakeTranslation(0, self.directionsView.bounds.size.height); //Shifts 0 pts right, and height pts down
    

    Note the use of “bounds” in the above code. The frame becomes undefined when you change the transform, so the view may move unpredictably if you try to set the frame (or base any other calculations on the current frame) when the transform is anything other than identity.

    (Disclaimer: code typed from memory–not tested in XCode.)

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

Sidebar

Related Questions

suppose we have this next sample code: while(some condition){ lock1.lock(); . . } the
Specifically, suppose I start with the string string =hello \'i am \' me And
Suppose I have this code: -(SomeOtherType*) getMyObject { SomeType someObject = [[SomeType alloc] init];
Suppose I have this code: class Num: def __init__(self,num): self.n = num def getn(self):
Suppose I have this: @Transactional(rollbackFor = NotificationException.class) public interface PersonManagerService { public void addPerson(Person
suppose I have the following source table (called S): name gender code Bob 0
Suppose I were to have a web application and a view called innerPage for
Suppose you set up a custom annotation public @interface ThreadSafe { } To indicate
suppose i have a .on() function wherein i select multiple ids $(#i, #am, #your,
Suppose I have a large list of words. For an example: >>> with open('/usr/share/dict/words')

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.