Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 8    Views: 309

PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
04/08/14 06:20 PM (10 years ago)

Changing the icon in a map pin's callout bubble

Hi folks, I'm trying to change the tappable(!) icon in a map pin callout bubble so it is the DetailDisclosure arrow (this type of thing: > ). The icon is currently showing as an 'InfoLight' icon, and it looks to be set in the MKAnnotationView method in BT_screen_map, like this: //ignore if button type is "none" if([tmpLoadScreenId isEqualToString:@"showDirections"]){ theButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; //what I've tried: if I change the previous line to this: // theButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; //my comment: nothing changes... }else{ if([tmpLoadScreenId length] > 1 || [tmpLoadScreenNickname length] > 1 || [tmpLocation.jsonVars objectForKey:@"loadScreenObject"]){ theButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; } The only other place anywhere in my app that refs "InfoLight" is in my customised nav bar settings in BT_viewController where I'm using the InfoLight system icon as a right nav button on my map screens (conditional to only those screens). There's no icon setting in my config.txt because these pins are generated via JSON set in a remote URL. And I haven't specified anywhere (to my knowledge!) that there should be a showDirections screen/action. As you can see above, changing InfoLight to DetailDisclosure in the code above isn't changing anything. Is there somewhere else I should be setting the callout bubble's icon? Or is the custom nav bar setting somehow setting InfoLight as the callout bubble icon for that same screen as well (ie it is applying my right nav button setting to the callout bubble because it is on the same screen)? Thanks! Cheers Paddy
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
04/09/14 04:51 AM (10 years ago)
Paddy, This may not be exactly what you want, but it's an interesting solution. http://nfarina.com/post/78014139253/smcalloutview-for-ios-7 Cheers! -- Smug
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
04/09/14 11:09 PM (10 years ago)
Nice find, Smug! I remember reading Nick's solution during the old days :-). Glad to see he has updated the technique for iOS 7. It's also insightful on how he used Reveal to peel back the layers of the UI. -- Niraj
 
PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
like
04/10/14 04:22 PM (10 years ago)
That looks like it has loads of potential Smug, thanks! Time to play some more! Cheers Paddy
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
04/10/14 05:31 PM (10 years ago)
Marking this so I can come back to it ;) Thanks Smug. Sounds great to add the image on left and ">". Reveal sounds like just what I need to see what is going wrong with my TabBar not appearing on some screens!
 
PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
like
04/12/14 05:30 AM (10 years ago)
Time to be embarrassed. Guess what: in iOS7, the UIButtonTypeDetailDisclosure is... wait for it ... EXACTLY the same image as UIButtonTypeInfoLight gives in both iOS6 AND iOS7. So it looks like there is no ">" type icon that's standard for callout bubbles in iOS7 any more. The code has been working perfectly. When I was changing UIButtonTypeInfoLight to UIButtonDetailDisclosure it made the change, it was just that the change is imperceptible because they give the SAME result. There's a few hours I'll never get back! But I learned heaps from everyone's pointers, thanks! Cheers Paddy.
 
PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
like
04/12/14 07:04 PM (10 years ago)
... and now that I've realised what was going on with the 'convergent' UIButtonType icon settings, the solution proved to be very simple (of course). Here's how I changed the tappable icon in my map's callout bubbles: 1. In BT_screen_map, find this in the 700-ish lines: //ignore if button type is "none" in BT_screen_map Change the code below it as follows: 2. Comment this out // if([tmpLoadScreenId isEqualToString:@"showDirections"]){ 3. add this instead: if([tmpLoadScreenId isEqualToString:@""]){ 4. Leave all this alone: theButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; }else{ if([tmpLoadScreenId length] > 1 || [tmpLoadScreenNickname length] > 1 || [tmpLocation.jsonVars objectForKey:@"loadScreenObject"]){ 5. But change this from '... UIButtonTypeWhateverTheDefaultWas" to this: theButton = [UIButton buttonWithType:UIButtonTypeCustom]; } } 6. Leave this alone: //if we have a button... add the appropriate tag + action (the tag tells us what location was tapped if(theButton != nil){ [theButton setTag:[annotation listIndex]]; 7. But add this immediately under it: [theButton setImage:[UIImage imageNamed:@"right_circle.png"] forState:UIControlStateNormal]; //or whatever other icon you want to use as your callout's tappable icon. That's it!! A nice alternative callout bubble icon to take you to your more detailed view of meta-info about your map pin. Lesson for today: in iOS7, UIButtonTypeInfoLight and UIButtonTypeDetailDisclosure show EXACTLY the same result. Hopefully this might help someone else too. Cheers Paddy.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
04/12/14 07:29 PM (10 years ago)
Good to know! This is going in my snippet box. Thanks Paddy! :) Cheers! -- Smug
 
PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
like
04/15/14 05:06 PM (10 years ago)
NCBuzz, have you tried Reveal yet? Just playing with it now - awesome stuff especially for me who gets lost inside all the controllers that control other controllers... it's beautiful! Thanks Smug! Cheers Paddy.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.