Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 20, 2012, 07:03 PM   #1
Blast12345
macrumors newbie
 
Join Date: Jul 2012
Change Text When At Coordinate

In this project, there are two map pins/annotations. When one is clicked on, a popup (separate xib file) pops up and will eventually display information (UILabels) about the pin you clicked on.

The issue I am having lies in the fact that I have multiple pins. I need to make my text in the xib file change based upon which pin was clicked on.

I was guessing that I could make this work using an if/else statement (If pinA is clicked, the display this information). Unfortunately, I have no idea what type of code is needed to perform this operation (if such code actually exists).

Another iOS programmer at my work suggested something involving tags, but I don't have enough experience with iOS/XCode to plop out the code based on his explanation (and I don't want take up too much of his time with this; he has his own work to do).

I have attached a file so that anyone can view my work as a whole. If you have any pointers, I would much appreciate it.
Attached Files
File Type: zip MapTestFinal copy 4 - Assist.zip (56.8 KB, 5 views)
Blast12345 is offline   0 Reply With Quote
Old Sep 21, 2012, 01:15 AM   #2
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
I have no experience with pins, but I'd say that you'll probably have them set up to invoke something like
Code:
- onTap:(Pin*) sender
You can then query sender to find out more data about it. As an example of how you could use this you could do:

Code:
switch (sender.tag) { ...
I don't know where the pins are created though. Did you set them up in a xib file? If so, you can check the identity inspector (right side of the window when you're editing xib files) and set the tag there. Or right after it's created in code, set its tag.

Just my thoughts.

And for in the future, don't upload .zips. I didn't download it, and I doubt anyone else will either. It's too much effort on our part to download your code, open it up, try to find the relevant sections, and then help you without just telling you the answer.

Instead, put the effort in to find the relevant parts that we'd be looking for if we did have the time to download your project, and post them directly to the forum. If it's a question relating to graphics, include a screenshot or something. If it's all code (most programming questions are,) then just copy and paste the relevant portion of code and remember to surrounding it was (code) and (/code) tags, with the ()'s replaced with their [] counterparts.
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
ArtOfWarfare is offline   0 Reply With Quote
Old Sep 21, 2012, 09:35 AM   #3
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by ArtOfWarfare View Post
I have no experience with pins, but I'd say that you'll probably have them set up to invoke something like
Code:
- onTap:(Pin*) sender
MKMapView can use a delegate (MKMapViewDelegate) that has a mapView:annotationView:calloutAccessoryControlTapped: delegate method. This sounds like the place to me to handle the presentation of the different views.

Side Note: ArtOfWarfare, if you have no experience with pins, IMHO, you don't need to be trying to address this part of the issue. And your answers could lead the OP astray and cause them unneeded frustration. I know you're eager to provide help, but consider how much help you are providing with a "shot-in-the-dark" answer.

Quote:
Originally Posted by Blast12345 View Post
Another iOS programmer at my work suggested something involving tags, but I don't have enough experience with iOS/XCode to plop out the code based on his explanation (and I don't want take up too much of his time with this; he has his own work to do).
If you have mapView:annotationView:calloutAccessoryControlTapped: implemented, provide us the code for that. Also, take a look at MKAnnotationView and see if there's a property in it (or within an ancestor class of it) that you can use to differentiate. I will say that using UIView's tag property is a pretty common way to go about this, and that's what I would recommend.
__________________
dejo is online now   0 Reply With Quote
Old Sep 21, 2012, 04:06 PM   #4
TheWatchfulOne
macrumors regular
 
Join Date: Jun 2009
Blast, can we have a little further explanation of what you are trying to do?

Are you presenting a call out over the pin before presenting the view?

Or are you skipping the call out and going straight to the view?

Deja gave you a good method to try but it sounds like you need to present a call out bubble with at least one accessory button in order to be able to use it.

Here's another method you might try:

Code:
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
This will allow you to get a reference to a selected annotation without presenting a call out bubble.

I have been working quite a bit with MapKit in my current project, so I do have some experience with it and I'll be happy to try to help you.
__________________
13" MacBook Pro, 2.26 GHz, 4 GB RAM, 500 GB HD iPhone 4 32GB 2nd gen iPod nano 4GB

Last edited by dejo; Sep 21, 2012 at 04:11 PM. Reason: Please use [code] tags.
TheWatchfulOne is online now   0 Reply With Quote
Old Sep 21, 2012, 10:13 PM   #5
Blast12345
Thread Starter
macrumors newbie
 
Join Date: Jul 2012
I got it working.

Code:
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
    NSString*locationTitle = [view.annotation title];


----bunch of code for my progams popup ui here----

            [_textOne setText:locationTitle];
}
The NSString*locationTitle grabs information from my map-pins information (coded in an earlier event).

I appreciate the code TheWatchfulOne. When I would close my xib popup and then click on the callout bubble, my app would crash. This answers a question before I even had to ask. Thanks!
Blast12345 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iPhone: Can't change text vibrations? Italianblend iOS 7 12 Oct 11, 2013 03:28 PM
For those having trouble getting text to change colors tymaster50 iOS 7 2 Jun 24, 2013 05:33 PM
How do I change the color of text in a table using pages J.Wildflower iPad Tips, Help and Troubleshooting 4 Jun 5, 2013 09:50 AM
iPhone: Want to change an app's text colour DigitL Jailbreaks and iOS Hacks 2 Apr 14, 2013 02:37 AM
change text color when people call. yea, sure iPhone 0 Feb 14, 2013 02:38 PM

Forum Jump

All times are GMT -5. The time now is 04:49 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC