<?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>Kickass Labs &#187; iPhone</title>
	<atom:link href="http://www.kickasslabs.com/category/iphone/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kickasslabs.com</link>
	<description>We &#9829; code.</description>
	<lastBuildDate>Sun, 04 Jul 2010 03:00:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Quick Hits: UIActionSheet cancel button strange behaviour</title>
		<link>http://www.kickasslabs.com/2010/07/03/uiactionsheet-cancel-button-strange-behaviour/</link>
		<comments>http://www.kickasslabs.com/2010/07/03/uiactionsheet-cancel-button-strange-behaviour/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 02:41:39 +0000</pubDate>
		<dc:creator>abel</dc:creator>
				<category><![CDATA[Quick Hits]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[objc]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.kickasslabs.com/2010/07/03/uiactionsheet-cancel-button-strange-behaviour/</guid>
		<description><![CDATA[I just got bit by this and fixed it thanks to this StackOverflow post.
http://stackoverflow.com/questions/1197746/uiactionsheet-cancel-button-strange-behaviour
Long story short, if your launch an action sheet in a view that lives in a UITabBarController, the &#8220;hit&#8221; box for the cancel button gets shifted in a VERY STUPID WAY!
The solution is to reference the view you&#8217;re displaying in by the [...]]]></description>
			<content:encoded><![CDATA[<p>I just got bit by this and fixed it thanks to this StackOverflow post.</p>
<p><a href="http://stackoverflow.com/questions/1197746/uiactionsheet-cancel-button-strange-behaviour" target="_blank">http://stackoverflow.com/questions/1197746/uiactionsheet-cancel-button-strange-behaviour</a></p>
<p>Long story short, if your launch an action sheet in a view that lives in a UITabBarController, the &#8220;hit&#8221; box for the cancel button gets shifted in a VERY STUPID WAY!</p>
<p>The solution is to reference the view you&#8217;re displaying in by the UITabBarController like this:</p>
<pre><code>[sheet showInView:self.parentViewController.tabBarController.view];</code></pre>
<p>Freaking WOW!  Thanks a heap, Apple!</p>
<p>*grumble grumble*</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.kickasslabs.com%2F2010%2F07%2F03%2Fuiactionsheet-cancel-button-strange-behaviour%2F&amp;linkname=Quick%20Hits%3A%20UIActionSheet%20cancel%20button%20strange%20behaviour"><img src="http://www.kickasslabs.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.kickasslabs.com/2010/07/03/uiactionsheet-cancel-button-strange-behaviour/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Quick Hits: Unit Testing iPhone Apps</title>
		<link>http://www.kickasslabs.com/2009/07/05/quick-hits-unit-testing-iphone-apps/</link>
		<comments>http://www.kickasslabs.com/2009/07/05/quick-hits-unit-testing-iphone-apps/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 19:04:35 +0000</pubDate>
		<dc:creator>Brad</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[objc]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://www.kickasslabs.com/?p=381</guid>
		<description><![CDATA[I have a few things to add to the woefully incomplete official documentation on setting up automated tests in your iPhone apps:

You need to add your main application executable target as a direct dependency of the test target, so that you&#8217;re always testing against your latest build.  Do this by double-clicking on the test [...]]]></description>
			<content:encoded><![CDATA[<p>I have a few things to add to the woefully incomplete <a href="http://developer.apple.com/IPhone/library/documentation/Xcode/Conceptual/iphone_development/135-Unit_Testing_Applications/unit_testing_applications.html" title="iPhone Development Guide: Unit Testing Applications" target="iphonetestdocs">official documentation on setting up automated tests in your iPhone apps</a>:</p>
<ol>
<li>You need to add your main application executable target as a direct dependency of the test target, so that you&#8217;re always testing against your latest build.  Do this by double-clicking on the test target, going to the &#8220;General&#8221; pane in the properties dialog, and adding your app under &#8220;Direct Dependencies&#8221;.  (This was actually mentioned in the OCUnit tutorial for Cocoa, but not the one about iPhone testing.)</li>
<li>Your linker needs to know about the objects you&#8217;re testing.  An easy way to do this is to add the .m files for those classes to the &#8220;Compile Sources&#8221; group in your test target.  You&#8217;ll also have to make sure you link against any frameworks used by these objects.  (You could also tell your app target to export all symbols, then link your test target to it as you would a library.) (Thanks to Chris Hanson for pointing out this procedural improvement in comments.) <del datetime="2009-07-06T02:48:59+00:00">You need to explicitly link the object files of the classes you&#8217;re testing.  These are the &#8220;.o&#8221; files in your build folder.  To do this: Double-click on the test target, go to the &#8220;General&#8221; pane, add a new item under &#8220;Linked Libraries&#8221;.  In the dialog that pops up, choose &#8220;Add Other&#8230;&#8221; and add your class&#8217;s .o file.</del></li>
<li>When you run your tests, one failure looks like two:  Failed tests show up in Xcode as errors (just like compile errors, &#038;c). Any test failure triggers a second error, and you&#8217;ll see something like &#8220;Failed tests for architecture &#8216;i386&#8242; (GC OFF)&#8221;. The docs never say so, but this appears to be normal.  Fix the failing test, and it goes away.</li>
</ol>
<p>Anything else to add?  Drop us a comment!</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.kickasslabs.com%2F2009%2F07%2F05%2Fquick-hits-unit-testing-iphone-apps%2F&amp;linkname=Quick%20Hits%3A%20Unit%20Testing%20iPhone%20Apps"><img src="http://www.kickasslabs.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.kickasslabs.com/2009/07/05/quick-hits-unit-testing-iphone-apps/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>UINavigationController Tricks</title>
		<link>http://www.kickasslabs.com/2009/07/03/uinavigationcontroller-tricks/</link>
		<comments>http://www.kickasslabs.com/2009/07/03/uinavigationcontroller-tricks/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 22:39:03 +0000</pubDate>
		<dc:creator>Brad</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[objc]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.kickasslabs.com/?p=366</guid>
		<description><![CDATA[For an iPhone UI I&#8217;m developing, I need to have one UINavigationController nested inside another, and to have the inner UINavigationController&#8217;s events push a view on to the outer one&#8217;s stack.  CocoaTouch didn&#8217;t give this to me for free, but there was a simple solution.
This post assumes that you&#8217;re familiar with the fundamentals of [...]]]></description>
			<content:encoded><![CDATA[<p>For an iPhone UI I&#8217;m developing, I need to have one UINavigationController nested inside another, and to have the inner UINavigationController&#8217;s events push a view on to the outer one&#8217;s stack.  CocoaTouch didn&#8217;t give this to me for free, but there <i>was</i> a simple solution.</p>
<p>This post assumes that you&#8217;re familiar with the fundamentals of iPhone programming, including view controllers, UINavigationController, and delegates.  There is <a href="http://www.kickasslabs.com/~kal_www/kickasslabs.com/wp-content/uploads/2009/07/navtest.tgz" title="UINavigationController Tricks sample code">sample code for this post</a>, which is released under version 2 of the <a href="http://sam.zoy.org/wtfpl/" title="WTFPL">WTFPL</a>.  </p>
<p><b>The Problem</b></p>
<p>I&#8217;m working on a multi-step UI for a game.  Expressing these steps as a regular drill-down table-style UI on the iPhone felt cumbersome, and games can&#8217;t afford for processes to feel cumbersome; people will stop playing.  One solution that occurred to me was batching related sets of steps in a smaller navigation table &#8211; so in Step 1 you&#8217;d drill through substeps 1A, 1B, and 1C before moving to Step 2.  The fact that the whole view wouldn&#8217;t be replaced with every choice seemed like it would be less destructive of the user&#8217;s mental context, and the chunking of substeps should make it easier for the users to wrap their heads around the process.  (No word yet on whether this solves my UI problem, but I like it so far.)</p>
<p>My UI solution contained its own technical problem, though: If I&#8217;m expressing the process steps in a UINavigationController, and expressing the substeps in a nested UINavigationController, how does the inner navigation controller notify the outer one that the user&#8217;s last substep choice completes that step and it&#8217;s time to move to the next step &#8211; or in programmatic terms, how does the inner UINavigationController tell the outer one to push a new view onto the outer one&#8217;s stack?</p>
<p>Or, putting it more visually, how do I get from here:</p>
<p><img src="http://www.kickasslabs.com/~kal_www/kickasslabs.com/wp-content/uploads/2009/07/navcontricks1.png" alt="navcontricks1" title="navcontricks1" width="414" height="770" class="aligncenter size-full wp-image-373" /></p>
<p>&#8230;to here:</p>
<p><img src="http://www.kickasslabs.com/~kal_www/kickasslabs.com/wp-content/uploads/2009/07/navcontricks2.png" alt="navcontricks2" title="navcontricks2" width="414" height="770" class="aligncenter size-full wp-image-374" /></p>
<p>In the non-nested situation when you wanted to push a new view onto a UINavigationController&#8217;s stack, you&#8217;d do the following in the current view:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>self.navigationController pushViewController<span style="color: #002200;">:</span>nextViewController animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>So in my nested case, I need to do that, but pushing onto the outer navigation controller&#8217;s stack from a view controller on the inner navigation controller&#8217;s stack.  I tried a number of naive (but sensible-seeming) targets for the pushViewController:animated: action, such as:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">self.navigationController.navigationController
self.navigationController.parentViewController.navigationController</pre></div></div>

<p>Nothing worked.  I set a breakpoint and drilled down through the members of self.navigationController, and no path to that outer UINavigationController was apparent.</p>
<p><b>The Solution</b></p>
<p>While investigating the innards of UINavigationController, I stumbled upon a writable property that looked like it might help: The delegate.  When creating the inner UINavigationController, I added one line of code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">innerNavCntlr.delegate <span style="color: #002200;">=</span> self; <span style="color: #11740a; font-style: italic;">// THIS IS THE MAGIC, PART 1</span></pre></div></div>

<p>Keep in mind that this is called in the view controller on top of the outer navigation controller&#8217;s stack, so &#8220;self&#8221; has access to the outer navigation controller.</p>
<p>When the view on top of my inner navigation controller&#8217;s stack is ready to signal the outer navigation controller, I do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// THIS IS THE MAGIC PART 2</span>
UIViewController <span style="color: #002200;">*</span>topVC <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>UIViewController <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>self.navigationController.delegate;
<span style="color: #002200;">&#91;</span>topVC.navigationController pushViewController<span style="color: #002200;">:</span>nextCntlr animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>A couple of notes:  First, the view controller that creates the inner UINavigationController must implement UINavigationControllerDelegate, or you&#8217;ll get a compiler warning &#8211; but you can just declare that it does so in the header file, as none of the methods in that interface are required.</p>
<p>Secondly: If you&#8217;re like me, this feels like an abuse of the delegate property.  Now there&#8217;s no reason that you couldn&#8217;t actually use that object productively as the inner navigation controller&#8217;s delegate &#8211; I just haven&#8217;t done so here.  And the fact that the delegate property has to be casted to be used this way says to me that it wasn&#8217;t meant for this &#8211; explicit casts are always a code smell.  (Anal-retentive types might want to put in some type-checking around that cast for safety.)</p>
<p>That said, it works, and I haven&#8217;t run into a maintainability problem yet, as this code doesn&#8217;t really get re-used in many places.  Were I expecting to use this trick often, I might package up a subclass of UINavigationController (call it NestedNavigationController) that actually took an outer UIViewController or UINavigationController property.  Then again I&#8217;m finding that in Cocoa, subclassing is often a code smell&#8230;</p>
<p>Got a better solution?  I&#8217;m interested &#8211; please leave a comment below!</p>
<p><b>Update:</b>  Whoops.  Comments are enabled now.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.kickasslabs.com%2F2009%2F07%2F03%2Fuinavigationcontroller-tricks%2F&amp;linkname=UINavigationController%20Tricks"><img src="http://www.kickasslabs.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.kickasslabs.com/2009/07/03/uinavigationcontroller-tricks/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>iPhone OS 3.0 GM Seed installation steps via iTunes &amp; XCode</title>
		<link>http://www.kickasslabs.com/2009/06/09/iphone-os-30-gm-seed-installation-steps-via-itunes-xcode/</link>
		<comments>http://www.kickasslabs.com/2009/06/09/iphone-os-30-gm-seed-installation-steps-via-itunes-xcode/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 14:07:02 +0000</pubDate>
		<dc:creator>abel</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[deployment]]></category>

		<guid isPermaLink="false">http://www.kickasslabs.com/?p=356</guid>
		<description><![CDATA[I couldn&#8217;t find these instructions in the iPhone Development portal, so I figured i&#8217;d share them with you here.  Once you download the appropriate GM seed, here&#8217;s how it&#8217;s done (I&#8217;m assuming you&#8217;ve already designated your phone as a dev device.):

Make sure&#8230;

to downloaded correct GM Seed for your iPhone (1st Gen or 3G).
that your system [...]]]></description>
			<content:encoded><![CDATA[<p>I couldn&#8217;t find these instructions in the iPhone Development portal, so I figured i&#8217;d share them with you here.  Once you download the appropriate GM seed, here&#8217;s how it&#8217;s done (I&#8217;m assuming you&#8217;ve already designated your phone as a dev device.):</p>
<ol>
<li>Make sure&#8230;
<ol>
<li>to downloaded correct GM Seed for your iPhone (1st Gen or 3G).</li>
<li>that your system and version of iTunes meet the requirements: 
<p>&#8220;You must be running Mac OS X v10.5.7 and iTunes 8.2 in order to install iPhone SDK 3.0 GM Seed and iPhone OS 3.0 GM Seed.&#8221;</p>
<p>&#8220;You must be running Mac OS X Snow Leopard Final Developer Preview (Build 10A380) and iTunes 8.2 in order to install the iPhone SDK 3.0 GM Seed for Snow Leopard and iPhone OS 3.0 GM Seed.&#8221;</p>
</li>
</ol>
</li>
<li>Extract the firmware .ipsw to a folder.</li>
<li>Connect the iPhone to your computer.</li>
<li><span style="color: #800000;"><strong>Back up your phone!</strong></span></li>
<li>Open iTunes and click Restore <span style="color: #0000ff;"><strong>while holding</strong></span> the Shift key (for Windows) or Option key (for Mac).</li>
<li>Locate or browse to the firmware IPSW.</li>
<li>Wait for iTunes to unpackage and install the firmware.</li>
</ol>
<p>OR you can just use Xcode&#8230;</p>
<ol>
<li><span style="color: #800000;"><strong>Back up your phone!</strong></span></li>
<li>Open Xcode</li>
<li>Open the Organizer (Window -&gt; Organizer)</li>
<li>Flip the software version to &#8220;Choose&#8230;&#8221;</li>
<li>Select the GM Seed ipsw file</li>
<li>You should  see a message that says something like &#8220;These changes will take effect when you restore you phone&#8221;</li>
<li>Click on the &#8220;Restore iPhone&#8221; button and watch the magic happen.</li>
</ol>
<p>By backing up your phone ahead of time, you&#8217;ll be able to tell iTunes to put all of your crap back on it when the process is done.  It&#8217;ll even try to preserve icon locations <img src='http://www.kickasslabs.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Happy hacking.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.kickasslabs.com%2F2009%2F06%2F09%2Fiphone-os-30-gm-seed-installation-steps-via-itunes-xcode%2F&amp;linkname=iPhone%20OS%203.0%20GM%20Seed%20installation%20steps%20via%20iTunes%20%26%23038%3B%20XCode"><img src="http://www.kickasslabs.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.kickasslabs.com/2009/06/09/iphone-os-30-gm-seed-installation-steps-via-itunes-xcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Hits:Deploying iPhone projects to your iPhone/iPod Touch</title>
		<link>http://www.kickasslabs.com/2009/06/04/quick-hitsdeploying-iphone-projects-to-your-iphoneipod-touch/</link>
		<comments>http://www.kickasslabs.com/2009/06/04/quick-hitsdeploying-iphone-projects-to-your-iphoneipod-touch/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 12:23:39 +0000</pubDate>
		<dc:creator>abel</dc:creator>
				<category><![CDATA[Quick Hits]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[process]]></category>

		<guid isPermaLink="false">http://www.kickasslabs.com/?p=350</guid>
		<description><![CDATA[This process sucks.  Period.  To get you through the suckage, I found this article with clear and useful steps.  If you&#8217;re becoming an iPhone/iPod Touch developer, this is something you NEED to read. The article presents the steps of the deployment process in the best order possible to improve your chances at [...]]]></description>
			<content:encoded><![CDATA[<p>This process sucks.  Period.  To get you through the suckage, I found this article with clear and useful steps.  If you&#8217;re becoming an iPhone/iPod Touch developer, this is something you NEED to read. The article presents the steps of the deployment process in the best order possible to improve your chances at a successful push.</p>
<p><a title="Deploying iPhone apps to real devices" href="http://mobiforge.com/developing/story/deploying-iphone-apps-real-devices" target="_blank">Deploying iPhone Apps to Real Devices</a></p>
<p>Happy hacking!</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.kickasslabs.com%2F2009%2F06%2F04%2Fquick-hitsdeploying-iphone-projects-to-your-iphoneipod-touch%2F&amp;linkname=Quick%20Hits%3ADeploying%20iPhone%20projects%20to%20your%20iPhone%2FiPod%20Touch"><img src="http://www.kickasslabs.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.kickasslabs.com/2009/06/04/quick-hitsdeploying-iphone-projects-to-your-iphoneipod-touch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Hits: A great FAQ for iPhone game developers</title>
		<link>http://www.kickasslabs.com/2009/05/30/quick-hits-a-great-faq-for-iphone-game-developers/</link>
		<comments>http://www.kickasslabs.com/2009/05/30/quick-hits-a-great-faq-for-iphone-game-developers/#comments</comments>
		<pubDate>Sat, 30 May 2009 16:51:11 +0000</pubDate>
		<dc:creator>abel</dc:creator>
				<category><![CDATA[Quick Hits]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[process]]></category>

		<guid isPermaLink="false">http://www.kickasslabs.com/?p=337</guid>
		<description><![CDATA[I came across this video from Brian Greenstone, the president and CEO of Pangea Software.  You might remember him from such iPhone games as Enigmo, Cro-Mag Rally, or Bugdom 2.
He&#8217;s made a video answering &#8220;10,000 ft view&#8221; questions about iPhone game development that people who are new to the platform should hear.  What he&#8217;s saying [...]]]></description>
			<content:encoded><![CDATA[<p>I came across this video from <span class="description">Brian Greenstone, the president and CEO of Pangea Software.  You might remember him from such iPhone games as <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=281736535&amp;mt=8">Enigmo</a>, <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=281747159&amp;mt=8">Cro-Mag Rally</a>, or <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291322250&amp;mt=8">Bugdom 2</a>.</span></p>
<p>He&#8217;s made a video answering &#8220;10,000 ft view&#8221; questions about iPhone game development that people who are new to the platform should hear.  What he&#8217;s saying isn&#8217;t revolutionary, but it&#8217;s a lot of very good advice in 1 spot.</p>
<p><object width="560" height="340" data="http://www.youtube.com/v/jjdJR_-ftns&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/jjdJR_-ftns&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /></object></p>
<p>Enjoy and happy hacking!</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.kickasslabs.com%2F2009%2F05%2F30%2Fquick-hits-a-great-faq-for-iphone-game-developers%2F&amp;linkname=Quick%20Hits%3A%20A%20great%20FAQ%20for%20iPhone%20game%20developers"><img src="http://www.kickasslabs.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.kickasslabs.com/2009/05/30/quick-hits-a-great-faq-for-iphone-game-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Maps events in Mobile Safari and PhoneGap for iPhone</title>
		<link>http://www.kickasslabs.com/2009/04/29/google-maps-events-in-mobile-safari-and-phonegap-for-iphone/</link>
		<comments>http://www.kickasslabs.com/2009/04/29/google-maps-events-in-mobile-safari-and-phonegap-for-iphone/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 20:23:27 +0000</pubDate>
		<dc:creator>Brad</dc:creator>
				<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[gmaps]]></category>

		<guid isPermaLink="false">http://www.kickasslabs.com/?p=255</guid>
		<description><![CDATA[Having trouble getting your Google Maps div to respond to events like you want in Mobile Safari or a PhoneGap app for iPhone?  So was I.  Disabling pinch-zoom is simple enough, but getting a finger drag to (a) not move the map and (b) draw something on the map was a major pain. [...]]]></description>
			<content:encoded><![CDATA[<p>Having trouble getting your <a href="http://code.google.com/apis/maps/" target="gmaps" title="Google Maps">Google Maps</a> div to respond to events like you want in Mobile Safari or a <a href="http://www.phonegap.com/" target="phonegap" title="PhoneGap">PhoneGap</a> app for iPhone?  So was I.  Disabling pinch-zoom is simple enough, but getting a finger drag to (a) not move the map and (b) draw something on the map was a major pain.  I share my solution below:  Proxying events through a transparent div overlaid on the Google Maps div.</p>
<p>To play along at home, you&#8217;ll need your own <a href="http://code.google.com/apis/maps/signup.html" target="gmaps_key" title="Google Maps API Key signup">Google Maps key</a> or you can just aim your mobile browser to my <a href="http://kickasslabs.com/examples/gmap_events.html" target="gmaps_example" title="Google Maps Event Proxying Example">example code at http://kickasslabs.com/examples/gmap_events.html</a>.  (Note that this will <i>not</i> work in a regular desktop browser.)  Besides a <tt>&lt;script&gt;</tt> tag importing the GMaps JavaScript, you should not need any other libraries or tools besides Mobile Safari to view and use the example page.  If the page is zoomed way out when you start, just double-tap the map tile in the upper-left corner &#8211; it should zoom to fill your viewport.</p>
<p>What you should see is a map tile with a line painted on it.  If you touch the screen, you should see one end of the line follow your finger.</p>
<p>It looks simple but I had a bit of trouble getting it to work, because touch events are not like mouse events (curious as to <a href="http://www.quirksmode.org/blog/archives/2008/08/iphone_events.html" target="mouse_vs_touch" title="Mouse vs. Touch">why?</a>), and GMaps doesn&#8217;t respond to touch events by default.</p>
<p><b>Step by Step</b></p>
<p>First, you need 2 divs:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">    &lt;!-- This div holds our map --&gt;
    &lt;div id=&quot;map&quot; style=&quot;width: 320; height: 320px&quot;&gt;&lt;/div&gt;
&nbsp;
    &lt;!-- This div lies on top of the map and acts as an event proxy --&gt;
    &lt;div id=&quot;mapoverlay&quot; style=&quot;height:320px; width: 320px; position: absolute;&quot;&gt;&lt;/div&gt;</pre></div></div>

<p>And you need to position one div over the other:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">    mapDiv = document.getElementById('map');
    mapOverlayDiv = document.getElementById('mapoverlay');
    mapOverlayDiv.style.top = (mapDiv.offsetTop + 0) + 'px';
    mapOverlayDiv.style.left = (mapDiv.offsetLeft + 0) + 'px';</pre></div></div>

<p>You set up the map div like you would for any other GMaps-enabled page:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">    // the map
    _map = new GMap2(document.getElementById(&quot;map&quot;));
&nbsp;
    // coordinates for home base
    _lat = 37;
    _lng = -95;
    mapCenter = new GLatLng(_lat, _lng);
    _map.setCenter(mapCenter, 15);</pre></div></div>

<p>Set up the overlay div to respond to touch events by firing a custom event for your map, e.g.:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">    mapOverlayDiv.ontouchstart = function(e) {
      GEvent.trigger(_map, 'customTouchStart',
        (e.touches[0].pageX - mapDiv.offsetLeft),
        (e.touches[0].pageY - mapDiv.offsetTop));
    }</pre></div></div>

<p>Now have your map respond to that event:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">    GEvent.addListener(_map, 'customTouchStart', mapTouchStart);</pre></div></div>

<p>&#8230;where <tt>mapTouchStart</tt> is a callback function that does something useful in response to a touch:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">    function mapTouchStart(xPixel, yPixel) {
      redrawLine(xPixel, yPixel);
    }</pre></div></div>

<p>And&#8230; well, then you&#8217;re done.  My example also responds to the touchMove event and has a little code for drawing lines, but you&#8217;ve seen all you need to know to get event proxying up and running for your app.</p>
<p>Got a question?  Got working code for an easier way?  Drop me a line in the comments!</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.kickasslabs.com%2F2009%2F04%2F29%2Fgoogle-maps-events-in-mobile-safari-and-phonegap-for-iphone%2F&amp;linkname=Google%20Maps%20events%20in%20Mobile%20Safari%20and%20PhoneGap%20for%20iPhone"><img src="http://www.kickasslabs.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.kickasslabs.com/2009/04/29/google-maps-events-in-mobile-safari-and-phonegap-for-iphone/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Resolving the CodeSign error in Xcode when building new iPhone projects</title>
		<link>http://www.kickasslabs.com/2008/12/13/resolving-the-codesign-error-in-xcode-when-building-new-iphone-projects/</link>
		<comments>http://www.kickasslabs.com/2008/12/13/resolving-the-codesign-error-in-xcode-when-building-new-iphone-projects/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 21:54:34 +0000</pubDate>
		<dc:creator>gabe</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[xcode codesign]]></category>

		<guid isPermaLink="false">http://www.kickasslabs.com/?p=126</guid>
		<description><![CDATA[Quick tip: if you&#8217;re just getting started with iPhone app development and trying to build and run an iPhone app project using the iPhone simulator in Xcode and you&#8217;re getting an error that looks like:
CodeSign error: Code Signing Identity &#8216;iPhone Developer&#8217; does not match any code-signing certificate in your keychain.  Once added to the [...]]]></description>
			<content:encoded><![CDATA[<p>Quick tip: if you&#8217;re just getting started with iPhone app development and trying to build and run an iPhone app project using the iPhone simulator in Xcode and you&#8217;re getting an error that looks like:</p>
<blockquote><p>CodeSign error: Code Signing Identity &#8216;iPhone Developer&#8217; does not match any code-signing certificate in your keychain.  Once added to the keychain, touch a file or clean the project to continue.</p></blockquote>
<p>The fix is pretty simple.  In the Build Results window (which you probably got to by clicking the error icon in the lower right corner of your project window), change the pulldown menu from &#8216;Device &#8211; iPhone xxx&#8217; to &#8216;Simulator &#8211; iPhone xxx&#8217;.  </p>
<p><img class="alignnone size-full wp-image-128" title="Xcode Device Pulldown Menu" src="http://www.kickasslabs.com/wp-content/uploads/2008/12/picture-1.jpg" alt="Xcode Device Pulldown Menu" width="253" height="304" /></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.kickasslabs.com%2F2008%2F12%2F13%2Fresolving-the-codesign-error-in-xcode-when-building-new-iphone-projects%2F&amp;linkname=Resolving%20the%20CodeSign%20error%20in%20Xcode%20when%20building%20new%20iPhone%20projects"><img src="http://www.kickasslabs.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.kickasslabs.com/2008/12/13/resolving-the-codesign-error-in-xcode-when-building-new-iphone-projects/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
