<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: A UIPickerView with labels</title>
	<atom:link href="http://blog.nottoobadsoftware.com/2009/03/a-uipickerview-with-labels/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nottoobadsoftware.com/2009/03/a-uipickerview-with-labels/</link>
	<description>Desktop UX / Software Design</description>
	<lastBuildDate>Tue, 24 Jan 2012 02:33:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: JeffW</title>
		<link>http://blog.nottoobadsoftware.com/2009/03/a-uipickerview-with-labels/comment-page-1/#comment-1651</link>
		<dc:creator>JeffW</dc:creator>
		<pubDate>Mon, 19 Jul 2010 19:26:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nottoobadsoftware.com/?p=22#comment-1651</guid>
		<description>I&#039;m working on a iOS 4.0 app, when I try to use a LabledPickerView I get an EXE_BAD_ACCESS at this line:

if ([self.delegate respondsToSelector:@selector(pickerView:didSelectRow:inComponent:)])
				[self.delegate pickerView:self didSelectRow:[self selectedRowInComponent:component] inComponent:component];

Has this code been broken by an Apple update, or am I doing something wrong?

Thanks!</description>
		<content:encoded><![CDATA[<p>I&#8217;m working on a iOS 4.0 app, when I try to use a LabledPickerView I get an EXE_BAD_ACCESS at this line:</p>
<p>if ([self.delegate respondsToSelector:@selector(pickerView:didSelectRow:inComponent:)])<br />
				[self.delegate pickerView:self didSelectRow:[self selectedRowInComponent:component] inComponent:component];</p>
<p>Has this code been broken by an Apple update, or am I doing something wrong?</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff</title>
		<link>http://blog.nottoobadsoftware.com/2009/03/a-uipickerview-with-labels/comment-page-1/#comment-462</link>
		<dc:creator>Jeff</dc:creator>
		<pubDate>Sat, 05 Sep 2009 03:02:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nottoobadsoftware.com/?p=22#comment-462</guid>
		<description>This is great stuff!

I did notice, however, that its calling &#039;didSelectRow&#039; upon creation (or at least when added to view).  I haven&#039;t narrowed it down exactly but has anyone else seen this?</description>
		<content:encoded><![CDATA[<p>This is great stuff!</p>
<p>I did notice, however, that its calling &#8216;didSelectRow&#8217; upon creation (or at least when added to view).  I haven&#8217;t narrowed it down exactly but has anyone else seen this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kare</title>
		<link>http://blog.nottoobadsoftware.com/2009/03/a-uipickerview-with-labels/comment-page-1/#comment-434</link>
		<dc:creator>Kare</dc:creator>
		<pubDate>Thu, 23 Jul 2009 23:27:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nottoobadsoftware.com/?p=22#comment-434</guid>
		<description>You&#039;re right. I fixed it so that method is no longer required. Well spotted.</description>
		<content:encoded><![CDATA[<p>You&#8217;re right. I fixed it so that method is no longer required. Well spotted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://blog.nottoobadsoftware.com/2009/03/a-uipickerview-with-labels/comment-page-1/#comment-433</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Fri, 17 Jul 2009 05:52:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nottoobadsoftware.com/?p=22#comment-433</guid>
		<description>Thanks for this useful little class! It&#039;s strange that the iPhone HIG recommends doing exactly this, yet doesn&#039;t suggest how to do it, nor do the APIs seem to support it easily!

By the way, I noticed that this class always tries to send a pickerView:didSelectRow:inComponent: message to its delegate, which crashes the app if the delegate doesn&#039;t implement that method. The regular UIPickerView doesn&#039;t do this, and indeed that method is listed as &quot;optional&quot; in the UIPickerViewDelegate protocol reference.

Otherwise, very nice work. Thanks again!</description>
		<content:encoded><![CDATA[<p>Thanks for this useful little class! It&#8217;s strange that the iPhone HIG recommends doing exactly this, yet doesn&#8217;t suggest how to do it, nor do the APIs seem to support it easily!</p>
<p>By the way, I noticed that this class always tries to send a pickerView:didSelectRow:inComponent: message to its delegate, which crashes the app if the delegate doesn&#8217;t implement that method. The regular UIPickerView doesn&#8217;t do this, and indeed that method is listed as &#8220;optional&#8221; in the UIPickerViewDelegate protocol reference.</p>
<p>Otherwise, very nice work. Thanks again!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kare</title>
		<link>http://blog.nottoobadsoftware.com/2009/03/a-uipickerview-with-labels/comment-page-1/#comment-425</link>
		<dc:creator>Kare</dc:creator>
		<pubDate>Fri, 05 Jun 2009 23:09:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nottoobadsoftware.com/?p=22#comment-425</guid>
		<description>Cleaned up the code a bit, should have been done long time ago obviously. And removed some completely unnecessary reloading of views.</description>
		<content:encoded><![CDATA[<p>Cleaned up the code a bit, should have been done long time ago obviously. And removed some completely unnecessary reloading of views.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kare</title>
		<link>http://blog.nottoobadsoftware.com/2009/03/a-uipickerview-with-labels/comment-page-1/#comment-24</link>
		<dc:creator>Kare</dc:creator>
		<pubDate>Wed, 22 Apr 2009 16:54:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nottoobadsoftware.com/?p=22#comment-24</guid>
		<description>I finally got around to updating mySettings with Michael&#039;s changes. Now just add something similar to this to your delegate and the labels will update automatically  when a new row is selected:
[code lang=&quot;objc&quot;]
// called when the wheel stops
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
	if (component == 0) {
		[(LabeledPickerView *)pickerView updateLabel:(row==1 ? @&quot;min&quot; : @&quot;mins&quot;) forComponent:0];
	} else if (component == 1) {
		[(LabeledPickerView *)pickerView updateLabel:(row==1 ? @&quot;sec&quot; : @&quot;secs&quot;) forComponent:1];
	}
}
[/code]
The latest version can be found here: &lt;a href=&quot;http://bitbucket.org/karemorstol/mysettings/raw/tip/Code/Generic classes/LabeledPickerView.h&quot; rel=&quot;nofollow&quot;&gt;LabeledPickerView.h&lt;/a&gt;, &lt;a href=&quot;http://bitbucket.org/karemorstol/mysettings/raw/tip/Code/Generic classes/LabeledPickerView.m&quot; rel=&quot;nofollow&quot;&gt;LabeledPickerView.m&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>I finally got around to updating mySettings with Michael&#8217;s changes. Now just add something similar to this to your delegate and the labels will update automatically  when a new row is selected:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="co2">// called when the wheel stops</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>pickerView<span class="sy0">:</span><span class="br0">&#40;</span>UIPickerView <span class="sy0">*</span><span class="br0">&#41;</span>pickerView didSelectRow<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>row inComponent<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>component <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>component <span class="sy0">==</span> <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span><span class="br0">&#40;</span>LabeledPickerView <span class="sy0">*</span><span class="br0">&#41;</span>pickerView updateLabel<span class="sy0">:</span><span class="br0">&#40;</span>row<span class="sy0">==</span><span class="nu0">1</span> ? <span class="co3">@</span><span class="st0">&quot;min&quot;</span> <span class="sy0">:</span> <span class="co3">@</span><span class="st0">&quot;mins&quot;</span><span class="br0">&#41;</span> forComponent<span class="sy0">:</span>0<span class="br0">&#93;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span>component <span class="sy0">==</span> <span class="nu0">1</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span><span class="br0">&#40;</span>LabeledPickerView <span class="sy0">*</span><span class="br0">&#41;</span>pickerView updateLabel<span class="sy0">:</span><span class="br0">&#40;</span>row<span class="sy0">==</span><span class="nu0">1</span> ? <span class="co3">@</span><span class="st0">&quot;sec&quot;</span> <span class="sy0">:</span> <span class="co3">@</span><span class="st0">&quot;secs&quot;</span><span class="br0">&#41;</span> forComponent<span class="sy0">:</span>1<span class="br0">&#93;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
</div>
<p>The latest version can be found here: <a href="http://bitbucket.org/karemorstol/mysettings/raw/tip/Code/Generic classes/LabeledPickerView.h" rel="nofollow">LabeledPickerView.h</a>, <a href="http://bitbucket.org/karemorstol/mysettings/raw/tip/Code/Generic classes/LabeledPickerView.m" rel="nofollow">LabeledPickerView.m</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Kaye</title>
		<link>http://blog.nottoobadsoftware.com/2009/03/a-uipickerview-with-labels/comment-page-1/#comment-13</link>
		<dc:creator>Michael Kaye</dc:creator>
		<pubDate>Mon, 30 Mar 2009 22:33:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nottoobadsoftware.com/?p=22#comment-13</guid>
		<description>sorry! In fact you only want to update the label if the label value has changed:

- (void) upDateLabel:(NSString *)labeltext forComponent:(NSUInteger)component {
	UILabel *theLabel = (UILabel*)[self viewWithTag:component];

        // Update label if it doesn&#039;t match current label
	if (theLabel.text != labeltext) {
		[UIView beginAnimations:nil context:NULL];
		[UIView setAnimationDuration:0.75];
		[UIView setAnimationCurve:UIViewAnimationCurveLinear];
		theLabel.alpha = 0.00;
		theLabel.text = labeltext;
		theLabel.alpha = 1.00;
		[UIView commitAnimations];
	}

}</description>
		<content:encoded><![CDATA[<p>sorry! In fact you only want to update the label if the label value has changed:</p>
<p>- (void) upDateLabel:(NSString *)labeltext forComponent:(NSUInteger)component {<br />
	UILabel *theLabel = (UILabel*)[self viewWithTag:component];</p>
<p>        // Update label if it doesn&#8217;t match current label<br />
	if (theLabel.text != labeltext) {<br />
		[UIView beginAnimations:nil context:NULL];<br />
		[UIView setAnimationDuration:0.75];<br />
		[UIView setAnimationCurve:UIViewAnimationCurveLinear];<br />
		theLabel.alpha = 0.00;<br />
		theLabel.text = labeltext;<br />
		theLabel.alpha = 1.00;<br />
		[UIView commitAnimations];<br />
	}</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Kaye</title>
		<link>http://blog.nottoobadsoftware.com/2009/03/a-uipickerview-with-labels/comment-page-1/#comment-12</link>
		<dc:creator>Michael Kaye</dc:creator>
		<pubDate>Mon, 30 Mar 2009 22:26:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nottoobadsoftware.com/?p=22#comment-12</guid>
		<description>In fact Apple animates the label change so you could do this to replicate what apple does (not sure about the timings though!:

- (void) upDateLabel:(NSString *)labeltext forComponent:(NSUInteger)component {
	UILabel *theLabel = (UILabel*)[self viewWithTag:component];

	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:0.75];
	[UIView setAnimationCurve:UIViewAnimationCurveLinear];
	theLabel.alpha = 0.00;
	theLabel.text = labeltext;
	theLabel.alpha = 1.00;
	[UIView commitAnimations];
}</description>
		<content:encoded><![CDATA[<p>In fact Apple animates the label change so you could do this to replicate what apple does (not sure about the timings though!:</p>
<p>- (void) upDateLabel:(NSString *)labeltext forComponent:(NSUInteger)component {<br />
	UILabel *theLabel = (UILabel*)[self viewWithTag:component];</p>
<p>	[UIView beginAnimations:nil context:NULL];<br />
	[UIView setAnimationDuration:0.75];<br />
	[UIView setAnimationCurve:UIViewAnimationCurveLinear];<br />
	theLabel.alpha = 0.00;<br />
	theLabel.text = labeltext;<br />
	theLabel.alpha = 1.00;<br />
	[UIView commitAnimations];<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Kaye</title>
		<link>http://blog.nottoobadsoftware.com/2009/03/a-uipickerview-with-labels/comment-page-1/#comment-11</link>
		<dc:creator>Michael Kaye</dc:creator>
		<pubDate>Mon, 30 Mar 2009 22:18:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nottoobadsoftware.com/?p=22#comment-11</guid>
		<description>Ok done...I needed to cast the viewWithTag to a UILabel of course,

I&#039;m sure there is a better way to do this but for the moment using the component as the tag is the easiest way because nothing else in your code needs to be modified. Also it makes it very easy to find the label view regardless of where it is added.

So please go ahead and add this in. 

Thanks again.

//add the following line

- (void)didMoveToWindow {
...
			label.tag = component;
...
}

// Update method
- (void) upDateLabel:(NSString *)labeltext forComponent:(NSUInteger)component {
	UILabel *theLabel = [self viewWithTag:component];
	theLabel.text = labeltext;
	//[theLabel setNeedsDisplay];
}

Obviously the best place to call the update method is in the pickerView didSelectRow method for the component being updated. i.e. [thePicker upDateLabel:NSLocalizedString(@&quot;minute&quot;, @&quot;&quot;) forComponent:1];

Thanks again for doing all the hard work.

Regards, Michael</description>
		<content:encoded><![CDATA[<p>Ok done&#8230;I needed to cast the viewWithTag to a UILabel of course,</p>
<p>I&#8217;m sure there is a better way to do this but for the moment using the component as the tag is the easiest way because nothing else in your code needs to be modified. Also it makes it very easy to find the label view regardless of where it is added.</p>
<p>So please go ahead and add this in. </p>
<p>Thanks again.</p>
<p>//add the following line</p>
<p>- (void)didMoveToWindow {<br />
&#8230;<br />
			label.tag = component;<br />
&#8230;<br />
}</p>
<p>// Update method<br />
- (void) upDateLabel:(NSString *)labeltext forComponent:(NSUInteger)component {<br />
	UILabel *theLabel = [self viewWithTag:component];<br />
	theLabel.text = labeltext;<br />
	//[theLabel setNeedsDisplay];<br />
}</p>
<p>Obviously the best place to call the update method is in the pickerView didSelectRow method for the component being updated. i.e. [thePicker upDateLabel:NSLocalizedString(@"minute", @"") forComponent:1];</p>
<p>Thanks again for doing all the hard work.</p>
<p>Regards, Michael</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Kaye</title>
		<link>http://blog.nottoobadsoftware.com/2009/03/a-uipickerview-with-labels/comment-page-1/#comment-10</link>
		<dc:creator>Michael Kaye</dc:creator>
		<pubDate>Mon, 30 Mar 2009 22:09:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nottoobadsoftware.com/?p=22#comment-10</guid>
		<description>Hi Kare,

Turns out it was a bug in another bit of code....so everything is working now (you don&#039;t even need setNeedsDisplay). 

I still have the warning though....which I&#039;m trying to sort now. When I do I&#039;ll come back to you.

Thanks, Michael.</description>
		<content:encoded><![CDATA[<p>Hi Kare,</p>
<p>Turns out it was a bug in another bit of code&#8230;.so everything is working now (you don&#8217;t even need setNeedsDisplay). </p>
<p>I still have the warning though&#8230;.which I&#8217;m trying to sort now. When I do I&#8217;ll come back to you.</p>
<p>Thanks, Michael.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

