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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

AppFusion - 6 in 1!
($0.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-03-2009, 12:51 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 7
Default Trigger MKAnnotationView Callout bubble

Hi,

I'm trying to display the callout bubble when a pin is dropped onto the map.
I looked into the docs and I see there's setSelected:animated: method.

But that won't call out the bubble.

How do I trigger the callout bubble of the pin?
seymores is offline   Reply With Quote
Old 06-03-2009, 05:30 AM   #2 (permalink)
aLoggers.com
 
Join Date: May 2009
Location: Minsk, Belarus
Posts: 17
Send a message via Skype™ to zaplitny
Default

Not sure I understood correctly but may be setCanShowCallout of MKAnnotationView is the thing you need
zaplitny is offline   Reply With Quote
Old 06-03-2009, 09:02 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 7
Default

My code looks something like the below. Using setCanShowCallout:YES doesn't do it.

Code:
  
   [annView setCanShowCallout:YES];
   [annView setSelected:YES animated:YES];
I need the callout bubble to show without the user tapping on the pin. Basically, once I add the pin to the map, the callout bubble should be displayed.

Is this possible with SDK 3.0?


Quote:
Originally Posted by zaplitny View Post
Not sure I understood correctly but may be setCanShowCallout of MKAnnotationView is the thing you need
seymores is offline   Reply With Quote
Old 06-11-2009, 03:01 AM   #4 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 7
Default

To those who is following, the answer is here:
How to trigger MKAnnotationView's callout view without touching the pin? - Stack Overflow

Quote:
Originally Posted by seymores View Post
My code looks something like the below. Using setCanShowCallout:YES doesn't do it.

Code:
  
   [annView setCanShowCallout:YES];
   [annView setSelected:YES animated:YES];
I need the callout bubble to show without the user tapping on the pin. Basically, once I add the pin to the map, the callout bubble should be displayed.

Is this possible with SDK 3.0?
seymores is offline   Reply With Quote
Old 06-19-2009, 03:05 AM   #5 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 2
Default

Quote:
Originally Posted by seymores View Post


Ok, here's there solution to this problem.

To display the callout use MKMapView#selectAnnotation:animated method.
hicatchme is offline   Reply With Quote
Old 06-25-2009, 07:16 AM   #6 (permalink)
hemali
 
Join Date: Nov 2008
Location: Ahmedabad
Age: 24
Posts: 12
Default Anotation view will open at thia place mark without toching placemarker

It is posibale with

///////////////////////////////////////////////

CLLocation *myPlaceLocation = [[CLLocation alloc] initWithLatitude:23.7899 longitude:75.890];
MyPlaceMark *myPlaceMark = [[MyPlaceMark alloc] initWithCoordinate:[myPlaceLocation coordinate]];
[myPlaceMark setAnootationTitle:@"My Place Mark"];
[myPlaceMark setAnootationSubTitle:@"My Place Mark"];
[myMapView addAnnotation:myPlaceMark];
//myMapView is instance of MKMapView class
[myMapView setCenterCoordinate:myPlaceLocation.coordinate animated:YES];
[myMapView setSelectedAnnotations:[[NSArray alloc] initWithObjects:myPlaceMark,nil]];


//////////////////////////////////////

Thanks,
Hemali Mojidra
Virtueinfo, Ahmedabad
hemalimojidra is offline   Reply With Quote
Old 08-04-2009, 04:39 AM   #7 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 2
Default Did it display annotation view without tapping pin ?

Quote:
Originally Posted by hemalimojidra View Post
It is posibale with

///////////////////////////////////////////////

CLLocation *myPlaceLocation = [[CLLocation alloc] initWithLatitude:23.7899 longitude:75.890];
MyPlaceMark *myPlaceMark = [[MyPlaceMark alloc] initWithCoordinate:[myPlaceLocation coordinate]];
[myPlaceMark setAnootationTitle:@"My Place Mark"];
[myPlaceMark setAnootationSubTitle:@"My Place Mark"];
[myMapView addAnnotation:myPlaceMark];
//myMapView is instance of MKMapView class
[myMapView setCenterCoordinate:myPlaceLocation.coordinate animated:YES];
[myMapView setSelectedAnnotations:[[NSArray alloc] initWithObjects:myPlaceMark,nil]];


//////////////////////////////////////

Thanks,
Hemali Mojidra
Virtueinfo, Ahmedabad
When I use this method, it doesn't display annotation view without tapping a pin. Am I missing something?

For your reference, here goes my sample code.
Code:
- (void)viewDidLoad {
    [super viewDidLoad];
	mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
	mapView.mapType = MKMapTypeStandard;
	mapView.delegate = self;
	[self.view addSubview:mapView];
	
	myPlaceLocation = [[CLLocation alloc] initWithLatitude:23.7899 longitude:75.890];
	myPlaceMark = [[MyLocation alloc] init];
	[myPlaceMark setCoordinate:[myPlaceLocation coordinate]];
	[myPlaceMark setTitle:@"My Place Mark"];
	[myPlaceMark setSubtitle:@"My Place Mark"];
	
	[mapView addAnnotation:myPlaceMark];
	//myMapView is instance of MKMapView class 
	[mapView setCenterCoordinate:myPlaceLocation.coordinate animated:YES];
	[mapView setSelectedAnnotations:[[NSArray alloc] initWithObjects:myPlaceMark,nil]];
}
Code:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
	MKPinAnnotationView *annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"sample"];
	
	annView.canShowCallout = YES;
	
	return annView;
}
slackwar is offline   Reply With Quote
Old 09-13-2009, 02:18 PM   #8 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 9
Default

Although [mapView selectAnnotation:currentAnnotation animated:FALSE] is the solution, but there is a catch to get it work consistently:

the code

for (id currentAnnotation in mapView.annotations) {
if ([currentAnnotation isEqual:annotationToSelect]) { [mapView selectAnnotation:currentAnnotation animated:FALSE]; } }

should be called from - (void)mapViewDidFinishLoadingMapMKMapView *)mapView, and nowhere else.

The underlying reason is a bit tricky:
The sequence in which the various methods like viewWillAppear, viewDidAppear of UIViewController and the - (void)mapViewDidFinishLoadingMapMKMapView *)mapView is called is different between the first time the map is loaded with one particular location and the subsequent times the map is displayed with the same location.
shibq is offline   Reply With Quote
Old 10-19-2009, 08:24 PM   #9 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 1
Default Thanks for the info this worked pretty well

Quote:
Originally Posted by shibq View Post
Although [mapView selectAnnotation:currentAnnotation animated:FALSE] is the solution, but there is a catch to get it work consistently:

the code

for (id currentAnnotation in mapView.annotations) {
if ([currentAnnotation isEqual:annotationToSelect]) { [mapView selectAnnotation:currentAnnotation animated:FALSE]; } }

should be called from - (void)mapViewDidFinishLoadingMapMKMapView *)mapView, and nowhere else.

The underlying reason is a bit tricky:
The sequence in which the various methods like viewWillAppear, viewDidAppear of UIViewController and the - (void)mapViewDidFinishLoadingMapMKMapView *)mapView is called is different between the first time the map is loaded with one particular location and the subsequent times the map is displayed with the same location.
I am using XCODE 3.1.4 with the 3.1.2 SDK and I found that I had to put this in both the mapViewDidFinishLoadingMap and in viewWillAppear in my map view controller class in order for it to work reliably. As you indicated, the order that methods are called for the first time is different for subsequent calls for the same location according to my code traces. I really appreciate the information provided here as I was unable to find it anywhere else.
loopyfrogger is offline   Reply With Quote
Reply

Bookmarks

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: 623
21 members and 602 guests
ADY, bandley, BrianSlick, Creativ, dacapo, Dattee, djbrooks111, gbenna, HDshot, IphoneSdk, iseff, jakerocheleau, jbro, joeallenpro, linkmx, mer10, nimesh_158, Reyna, ukneeq, yurikus
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 160,619
Threads: 89,833
Posts: 383,490
Top Poster: BrianSlick (7,244)
Welcome to our newest member, yurikus
Powered by vBadvanced CMPS v3.1.0

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