<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JAKERI &#187; property change listener</title>
	<atom:link href="http://www.jakeri.net/tag/property-change-listener/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jakeri.net</link>
	<description>Java, JEE, Objective-C, Scalability, High-Availability, e-Commerce etc...</description>
	<lastBuildDate>Tue, 26 Jul 2011 19:27:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Revisited &#8211; Custom callout bubble in MKMapView, final solution!</title>
		<link>http://www.jakeri.net/2010/05/custom-callout-bubble-final-solution-revisited/</link>
		<comments>http://www.jakeri.net/2010/05/custom-callout-bubble-final-solution-revisited/#comments</comments>
		<pubDate>Sun, 16 May 2010 18:03:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[callout bubble]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[mkannotation]]></category>
		<category><![CDATA[mkannotationview]]></category>
		<category><![CDATA[mkmapview]]></category>
		<category><![CDATA[property change listener]]></category>

		<guid isPermaLink="false">http://www.jakeri.net/?p=392</guid>
		<description><![CDATA[I thought I had the final solution for custom callout bubbles in MKMapView but I was wrong. There were a couple of errors found after testing. If you press and hold it moves focus to the real callout bubble offset &#8230; <a href="http://www.jakeri.net/2010/05/custom-callout-bubble-final-solution-revisited/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I thought I had the <a href="http://www.jakeri.net/2009/12/custom-callout-bubble-in-mkmapview-final-solution/">final solution for custom callout bubbles in MKMapView</a> but I was wrong. There were a couple of errors found after testing.</p>
<ul>
<li>If you press and hold it moves focus to the real callout bubble offset 10000px right and 10000px down</li>
<li>It did not work on the iPad (iPhoneOS 3.2) and iPhoneOS 4.0</li>
<li>There is a leak on the property observer</li>
</ul>
<p>My latest solution solves the first two but not the third one. It works with iPhoneOS 3.0, 3.1, 3.2 and 4.0. I have only tested in simulator for 3.2 and 4.0.</p>
<p>To make it a easier to look at the code I have created my first <a href="http://github.com/jakeri/CustomCalloutMapView">github repository</a>. You can alsoe download source for master (<a href="http://github.com/jakeri/CustomCalloutMapView/zipball/master">zip</a> or <a href="http://github.com/jakeri/CustomCalloutMapView/tarball/master">tar</a>) directly from github.</p>
<p><strong>Update:</strong> I got my <a href="http://www.jakeri.net/gasmacken">application</a>, <a href="http://www.jakeri.net/gasmacken">Gasmacken</a> approved (2010-05-23) with this solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jakeri.net/2010/05/custom-callout-bubble-final-solution-revisited/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Custom callout bubble in MKMapView, final solution!</title>
		<link>http://www.jakeri.net/2009/12/custom-callout-bubble-in-mkmapview-final-solution/</link>
		<comments>http://www.jakeri.net/2009/12/custom-callout-bubble-in-mkmapview-final-solution/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 13:20:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[callout bubble]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[mkannotation]]></category>
		<category><![CDATA[mkannotationview]]></category>
		<category><![CDATA[mkmapview]]></category>
		<category><![CDATA[property change listener]]></category>

		<guid isPermaLink="false">http://www.jakeri.net/?p=349</guid>
		<description><![CDATA[Once again, this post has been updated. I was not completely satisfied with my prior solution to custom callout bubble in MKMapView due a drawback. One drawback is that if you click an annotation in the TouchView it is not &#8230; <a href="http://www.jakeri.net/2009/12/custom-callout-bubble-in-mkmapview-final-solution/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Once again, this post has been <a href="http://www.jakeri.net/2010/05/custom-callout-bubble-final-solution-revisited/">updated</a>.</p>
<p>I was not completely satisfied with my prior solution to <a href="http://www.jakeri.net/2009/11/custom-callout-bubble-to-mkmapview-in-iphone/">custom callout bubble in MKMapView</a> due a drawback.</p>
<blockquote><p>One drawback is that if you click an annotation in the TouchView it is not propagated down to the MKMapView which makes pinch zoom bit more tricky if you have many annotations. Someone out there might have a good solution for it?</p></blockquote>
<p>Fortunately I figured out a new solution for the problem! A much more simple solution too.</p>
<p>It is a combination of the <a href="http://blog.evandavey.com/2009/07/how-to-detect-when-mkannotation-mkannotationview-is-selected.html">property change listener</a> solution and moving the <a href="http://developer.apple.com/iphone/library/documentation/MapKit/Reference/MKAnnotationView_Class/Reference/Reference.html#//apple_ref/occ/instp/MKAnnotationView/calloutOffset">calloutOffset</a> off the display.</p>
<p>Set the calloutOffset off the display and add an observer to the selected-property.<br />
<code>- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation {</code></p>
<p><code>MKAnnotationView* annotationView = nil;</code></p>
<p><code>MyAnnotation *myAnnotation = (MyAnnotation*) annotation;<br />
NSString* identifier = @"Pin";<br />
MKPinAnnotationView* annView = (MKPinAnnotationView*)[self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];</code></p>
<p><code> </code></p>
<p><code>if(nil == annView) {<br />
annView = [[[MKPinAnnotationView alloc] initWithAnnotation:myAnnotation reuseIdentifier:identifier] autorelease];<br />
}<br />
//Add an observer for the selected-property on the MKAnnotationView. Delegate to self.<br />
[annView addObserver:self<br />
forKeyPath:@"selected"<br />
options:NSKeyValueObservingOptionNew<br />
context:GMAP_ANNOTATION_SELECTED];</code></p>
<p><code> </code></p>
<p><code>[annView setPinColor:MKPinAnnotationColorGreen];</p>
<p>//Set calloutOffset off screen.<br />
CGPoint notNear = CGPointMake(10000.0,10000.0);<br />
annView.calloutOffset = notNear;<br />
annotationView = annView;</p>
<p>[annotationView setEnabled:YES];<br />
[annotationView setCanShowCallout:YES];</p>
<p></code></p>
<p><code> return annotationView;<br />
}</code></p>
<p>Implement the observeValueForKeyPath method. It will be triggered when the property is selected or deselected.<br />
<code><br />
- (void)observeValueForKeyPath:(NSString *)keyPath<br />
ofObject:(id)object<br />
change:(NSDictionary *)change<br />
context:(void *)context{</code></p>
<p><code>NSString *action = (NSString*)context;</code></p>
<p><code> </code></p>
<p><code> if([action isEqualToString:GMAP_ANNOTATION_SELECTED]){<br />
BOOL annotationAppeared = [[change valueForKey:@"new"] boolValue];<br />
if (annotationAppeared) {<br />
[self showAnnotation:((MyAnnotationView*) object).annotation];<br />
}<br />
else {<br />
NSLog(@"annotation deselected %@", ((MyAnnotationView*) object).annotation.title);<br />
[self hideAnnotation];<br />
}<br />
}<br />
}<br />
</code></p>
<p><a href="http://www.jakeri.net/wp-content/uploads/2009/12/Screenshot_17.png"><img class="alignnone size-medium wp-image-363" title="Screenshot_17" src="http://www.jakeri.net/wp-content/uploads/2009/12/Screenshot_17-156x300.png" alt="Screenshot_17" width="156" height="300" /></a></p>
<p>Take a look at my <a href="http://www.jakeri.net/wp-content/uploads/2009/12/FinalCustomCalloutMapView.zip">new example</a> (with standard MKPinAnnotationView) or with <a href="http://www.jakeri.net/wp-content/uploads/2009/12/CustomCalloutMapView-custom-annotationView.zip">custom annotation view</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jakeri.net/2009/12/custom-callout-bubble-in-mkmapview-final-solution/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
	</channel>
</rss>

