<?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>Rune&#039;s Blog &#187; uitabbarcontroller</title>
	<atom:link href="http://runmad.com/blog/tag/uitabbarcontroller/feed/" rel="self" type="application/rss+xml" />
	<link>http://runmad.com/blog</link>
	<description>A blog about code, graphics, UI, marketing and whatever else interests me. Follow me on Twitter: @runmad</description>
	<lastBuildDate>Sat, 28 Jan 2012 14:08:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>UITabBarController and UIActionSheet &#8211; 65% less hit point!</title>
		<link>http://runmad.com/blog/2010/04/uitabbarcontroller-and-uiactionsheet-65-percent-less-hit-point/</link>
		<comments>http://runmad.com/blog/2010/04/uitabbarcontroller-and-uiactionsheet-65-percent-less-hit-point/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 16:05:33 +0000</pubDate>
		<dc:creator>Rune Madsen</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[uiactionsheet]]></category>
		<category><![CDATA[uiapplication]]></category>
		<category><![CDATA[uitabbarcontroller]]></category>

		<guid isPermaLink="false">http://runmad.com/blog/?p=111</guid>
		<description><![CDATA[Ever noticed an app where the UIActionSheet&#8217;s bottom button doesn&#8217;t want to respond to your taps, unless you hit exactly in the top of the button? If you have a UITabBarController and want to display a UIActionSheet, you have to be careful with what view you show the UIActionSheet in. If a UIActionSheet is shown [...]]]></description>
			<content:encoded><![CDATA[<p>Ever noticed an app where the UIActionSheet&#8217;s bottom button doesn&#8217;t want to respond to your taps, unless you hit exactly in the top of the button? If you have a UITabBarController and want to display a UIActionSheet, you have to be careful with what view you show the UIActionSheet in.</p>
<p>If a UIActionSheet is shown in &#8220;self&#8221; or &#8220;self.view&#8221; and you got a UITabBarController behind it less than half of the last button will respond to taps:</p>
<div style="margin:0px 0px 20px;text-align:left;color:#000000; background-color:#F1EFE6; border: 1px solid rgb(211, 209, 199); padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#400080;">UIActionSheet</span> *actionSheet = [[<span style="color:#400080;">UIActionSheet</span> <span style="color:#ff0000;">alloc</span>] <span style="color:#6c0540;">initWithTitle:</span><span style="color:#760f15;">@&quot;UIActionSheet Title&quot;</span> <span style="color:#6c0540;">delegate:</span><span style="color:#881350;">nil</span> <span style="color:#6c0540;">cancelButtonTitle:</span><span style="color:#760f15;">@&quot;Cancel&quot;</span> <span style="color:#6c0540;">destructiveButtonTitle:</span><span style="color:#881350;">nil</span> <span style="color:#6c0540;">otherButtonTitles:</span><span style="color:#760f15;">@&quot;Option 1&quot;</span>, <span style="color:#760f15;">@&quot;Option 2&quot;</span>, <span style="color:#881350;">nil</span>];<br />
actionSheet.actionSheetStyle = <span style="color:#400080;">UIActionSheetStyleBlackTranslucent</span>;<br />
[actionSheet <span style="color:#6c0540;">showInView:</span><span style="color:#881350;">self</span>];<br />
[actionSheet <span style="color:#ff0000;">release</span>];</div>
<p>Here&#8217;s how much of the button will actually respond to taps:</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-112" title="cannothituiactionsheet" src="http://runmad.com/blog/wp-content/uploads/2010/04/cannothituiactionsheet.png" alt="" width="414" height="251" /></p>
<p>Here&#8217;s what you need to do to fix it:</p>
<div style="margin:0px 0px 20px;text-align:left;color:#000000; background-color:#F1EFE6; border: 1px solid rgb(211, 209, 199); padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; ">[actionSheet <span style="color:#6c0540;">showInView:</span>[[[<span style="color:#400080;">UIApplication</span> <span style="color:#6c0540;">sharedApplication</span>] <span style="color:#6c0540;">windows</span>] <span style="color:#6c0540;">objectAtIndex:</span><span style="color:#0000ff;">0</span>]];</div>
<p>And what it does:</p>
<p><img class="aligncenter size-full wp-image-115" title="canhituiactionsheet" src="http://runmad.com/blog/wp-content/uploads/2010/04/canhituiactionsheet.png" alt="" width="414" height="251" /></p>
]]></content:encoded>
			<wfw:commentRss>http://runmad.com/blog/2010/04/uitabbarcontroller-and-uiactionsheet-65-percent-less-hit-point/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Colouring fun with moreNavigationController</title>
		<link>http://runmad.com/blog/2010/01/coloring-fun-with-morenavigationcontroller-and-it/</link>
		<comments>http://runmad.com/blog/2010/01/coloring-fun-with-morenavigationcontroller-and-it/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 16:03:40 +0000</pubDate>
		<dc:creator>Rune Madsen</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[barStyle]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[morenavigationcontroller]]></category>
		<category><![CDATA[tintColor]]></category>
		<category><![CDATA[uitabbarcontroller]]></category>

		<guid isPermaLink="false">http://www.davesenior.com/rune/?p=95</guid>
		<description><![CDATA[When adding more than 5 view controllers to your UITabBarController, a &#8220;More&#8221; tab is automatically setup for you, which includes a view controller and even a modal view for letting the user edit the app&#8217;s tabs in the order they want. By default, the navigation bars for both the moreNavigationController and the modal view (edit) [...]]]></description>
			<content:encoded><![CDATA[<p>When adding more than 5 view controllers to your <em>UITabBarController</em>, a &#8220;More&#8221; tab is automatically setup for you, which includes a view controller and even a modal view for letting the user edit the app&#8217;s tabs in the order they want.</p>
<p>By default, the navigation bars for both the <em>moreNavigationController</em> and the modal view (edit) are the Default blue, but changing these colours isn&#8217;t exactly straightforward.</p>
<p>Here&#8217;s an example of what we want to achieve:</p>
<p><a href="http://runmad.com/blog/wp-content/uploads/2010/01/55780969-9ac509b43e33b4791a779eddd953138c.4b48a8ff-full1.png"><img class="aligncenter size-full wp-image-126" title="Custom colour in your moreViewController's navigation bar" src="http://runmad.com/blog/wp-content/uploads/2010/01/55780969-9ac509b43e33b4791a779eddd953138c.4b48a8ff-full1.png" alt="" width="414" height="770" /></a></p>
<p>I use an orange colour in one of my apps for the navigation bars and it just looks wrong when the more tab&#8217;s navigation bars are blue.</p>
<p>Changing the colour of the <em>moreNavigationController</em> is quite easy. After you alloc the <em>UITabBarController</em>, set the colour of the <em>moreNavigationController</em>:</p>
<div style="margin:0px 0px 20px;text-align:left;color:#000000; background-color:#F1EFE6; border: 1px solid rgb(211, 209, 199); padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; ">tabBarController.moreNavigationController.navigationBar.tintColor = [<span style="color:#400080;">UIColor</span> <span style="color:#6c0540;">orangeColor</span>];</div>
<p>You can also use the <em>barStyle</em> property if you like:</p>
<div style="margin:0px 0px 20px;text-align:left;color:#000000; background-color:#F1EFE6; border: 1px solid rgb(211, 209, 199); padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; ">tabBarController.moreNavigationController.navigationBar.barStyle = <span style="color:#400080;">UIBarStyleBlackOpaque</span>;</div>
<p>That wasn&#8217;t so hard. But the navigation bar for the modal view that pops up when the user taps &#8220;Edit&#8221; is still the default blue. So let&#8217;s change that as well:</p>
<p>First, if you haven&#8217;t already, make sure your AppDelegate implements the <em>UITabBarControllerDelegate</em>. Then add the optional delegate method <em>willBeginCustomizingViewControllers:</em> in your AppDelegate&#8217;s implementation file, and add the following lines of code:</p>
<div style="margin:0px 0px 20px;text-align:left;color:#000000; background-color:#F1EFE6; border: 1px solid rgb(211, 209, 199); padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; ">- (<span style="color:#881350;">void</span>)<span style="color:#6c0540;">tabBarController:</span>(<span style="color:#400080;">UITabBarController</span> *)controller <span style="color:#6c0540;">willBeginCustomizingViewControllers:</span>(<span style="color:#400080;">NSArray</span> *)viewControllers {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">UIView</span> *editView = [controller.view.subviews <span style="color:#6c0540;">objectAtIndex:</span><span style="color:#0000ff;">1</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">UINavigationBar</span> *modalNavBar = [editView.subviews <span style="color:#6c0540;">objectAtIndex:</span><span style="color:#0000ff;">0</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;modalNavBar.tintColor = [<span style="color:#400080;">UIColor</span> <span style="color:#6c0540;">orangeColor</span>];<br />
}</div>
<p>Again, it&#8217;s possible to set the <em>barStyle</em> property instead of the <em>tintColor</em>, but <em>barStyle</em> won&#8217;t give you all the colour options, of course.</p>
<p>Now that you have gained control of the modal view, you change more properties. By default, the navigation bar title says &#8220;Configure&#8221;, but you can change that as well, or how about the background colour? Here&#8217;s how:</p>
<div style="margin:0px 0px 20px;text-align:left;color:#000000; background-color:#F1EFE6; border: 1px solid rgb(211, 209, 199); padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; ">- (<span style="color:#881350;">void</span>)<span style="color:#6c0540;">tabBarController:</span>(<span style="color:#400080;">UITabBarController</span> *)controller <span style="color:#6c0540;">willBeginCustomizingViewControllers:</span>(<span style="color:#400080;">NSArray</span> *)viewControllers {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">UIView</span> *editView = [controller.view.subviews <span style="color:#6c0540;">objectAtIndex:</span><span style="color:#0000ff;">1</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;editView.backgroundColor = [<span style="color:#400080;">UIColor</span> <span style="color:#6c0540;">grayColor</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">UINavigationBar</span> *modalNavBar = [editView.subviews <span style="color:#6c0540;">objectAtIndex:</span><span style="color:#0000ff;">0</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;modalNavBar.tintColor = [<span style="color:#400080;">UIColor</span> <span style="color:#6c0540;">orangeColor</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;modalNavBar.topItem.title = <span style="color:#760f15;">@&quot;Edit Tabs&quot;</span>;<br />
}</div>
<p>Regarding the HIG&#8230; I am not sure if all this is allowed. I will be submitting an update with an orange coloured navigation bar for both those views, and I believe other apps have it (NY Times) so I don&#8217;t think it goes against the HIG.</p>
<p>However, I don&#8217;t think it&#8217;s a good idea to change the <em>backgroundColor</em> property of the &#8220;editView&#8221;. I tried with a grey colour and it doesn&#8217;t look right. It might also get your app rejected, because it&#8217;s such a big change. That your navigation bars are the same colour throughout your app only makes it look better in my opinion, rather than having a blue navigation bar clash with the rest of your beautifully designed app :)</p>
]]></content:encoded>
			<wfw:commentRss>http://runmad.com/blog/2010/01/coloring-fun-with-morenavigationcontroller-and-it/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

