Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-27-2011, 03:46 PM   #1 (permalink)
Registered Member
 
iphonig's Avatar
 
Join Date: Sep 2009
Location: United States
Posts: 73
iphonig is on a distinguished road
Default Custom Map Pin Image

fixed
__________________
Check Out All of Our Apps Here!

Last edited by iphonig; 06-28-2011 at 11:31 AM.
iphonig is offline   Reply With Quote
Old 06-27-2011, 04:38 PM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

You do not compare strings with "==", you use isEqualToString:
smithdale87 is offline   Reply With Quote
Old 06-27-2011, 09:57 PM   #3 (permalink)
Registered Member
 
iphonig's Avatar
 
Join Date: Sep 2009
Location: United States
Posts: 73
iphonig is on a distinguished road
Default

problem was fixed
__________________
Check Out All of Our Apps Here!

Last edited by iphonig; 06-28-2011 at 11:31 AM.
iphonig is offline   Reply With Quote
Old 06-28-2011, 03:20 AM   #4 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

Code:
  return anView;
    [anView release];
}
this make no sense, you should return an autoreleased object, you can't release after a return
__________________
dany_dev is offline   Reply With Quote
Old 06-28-2011, 07:35 AM   #5 (permalink)
Registered Member
 
iphonig's Avatar
 
Join Date: Sep 2009
Location: United States
Posts: 73
iphonig is on a distinguished road
Default

problem was fixed
__________________
Check Out All of Our Apps Here!

Last edited by iphonig; 06-28-2011 at 11:32 AM.
iphonig is offline   Reply With Quote
Old 06-28-2011, 08:35 AM   #6 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by iphonig View Post
Hey All,

I am working on an app right now and I have the colors of the pins changing when I want them to, but as I'm sure a lot of you are well aware, Apple limits you to only using red, green, and purple pins. I figured out how to have an image show rather than one of Apple's own colored pins but the problem is I will click the button that makes the custom pin drop and it will work fine. But if I press it again (and yes there are supposed to be multiple pins on the map) red pins show up rather than the custom ones again. The code I wrote out is below. Any ideas?

Code:
- (MKAnnotationView *) mapView:(MKMapView *)mapView 
             viewForAnnotation:(id <MKAnnotation>) annotation {
    MKPinAnnotationView *anView =[[MKPinAnnotationView alloc] 
                                  initWithAnnotation:annotation reuseIdentifier:@"pin"];
    if(pinColor == @"red")
        anView.pinColor = MKPinAnnotationColorRed;
    if(pinColor == @"green")
        anView.pinColor = MKPinAnnotationColorGreen;
    if(pinColor == @"amber")
        anView.image = [UIImage imageNamed:@"amberpin.png"];
    
    anView.animatesDrop = TRUE;
	anView.canShowCallout = YES;

    return anView;
    [anView release];
}
BTW 'annotation' is pointer to a MapAnnotation class I have written.

I add the pins with

Code:
[mapView addAnnotation:annotation];
Again any help would be appreciated!

Looking at it more closely, this code has all kinds of problems.

1. You're not calling dequeueReusableAnnotationViewWithIdentifier to check for a recycled annotation view.

2. You're always creating an instance of MKPinAnnotationView. That type only supports one of the standard pin annotations. You need to first decide what kind of annotation view you need, and THEN use the code that dequeues/creates the right kind of annotation view.

3. You should autorelease your annotation view, not release it.

4. You have a release call after the return. That line of code will never get called. You need to put the (autorelease) before the return.

There may be other problems too. I didn't proof it that carefully.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 06-28-2011, 08:38 AM   #7 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by iphonig View Post
So this?

Code:
 [anView autorelease];
    return anView;
    [mapView setDelegate:self]; //NO!!!!!!!! This does not belong here, for lots of reasons.

Dude,

When you execute a return statement, the program returns from your method. Any code after a return is not executed. Why do you insist on putting lines of (dead) code after your return?

Also, you should not be calling mapView setDelegate inside your view for annotation method. You should set up your mapview's delegate once and only once, usually in the awakeFromNib method. You can even set up the delegate in interface builder.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 06-28-2011, 09:09 AM   #8 (permalink)
Registered Member
 
iphonig's Avatar
 
Join Date: Sep 2009
Location: United States
Posts: 73
iphonig is on a distinguished road
Default

problem was fixed
__________________
Check Out All of Our Apps Here!

Last edited by iphonig; 06-28-2011 at 11:32 AM.
iphonig is offline   Reply With Quote
Old 06-28-2011, 10:29 AM   #9 (permalink)
Registered Member
 
iphonig's Avatar
 
Join Date: Sep 2009
Location: United States
Posts: 73
iphonig is on a distinguished road
Default

NVM EVERYTHING IS FIXED! I accidentally over released somewhere
__________________
Check Out All of Our Apps Here!

Last edited by iphonig; 06-28-2011 at 11:32 AM.
iphonig is offline   Reply With Quote
Reply

Bookmarks

Tags
annotation, custom, kit, map, pin

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 328
8 members and 320 guests
chemistry, Dnnake, iOS.Lover, lendo, leostc, Leslie80, pbart, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,664
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Leslie80
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:29 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0