<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Miscellanea</title>
	<atom:link href="http://userflex.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://userflex.wordpress.com</link>
	<description>Tasty tidbits of Flex and iOS knowledge</description>
	<lastBuildDate>Thu, 26 Jan 2012 21:05:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='userflex.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Miscellanea</title>
		<link>http://userflex.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://userflex.wordpress.com/osd.xml" title="Miscellanea" />
	<atom:link rel='hub' href='http://userflex.wordpress.com/?pushpress=hub'/>
		<item>
		<title>How to Add a Custom Info Button to a UINavigationItem</title>
		<link>http://userflex.wordpress.com/2012/01/26/info-button-uinavigationitem/</link>
		<comments>http://userflex.wordpress.com/2012/01/26/info-button-uinavigationitem/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 21:00:53 +0000</pubDate>
		<dc:creator>Nick Schneble</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[info button]]></category>
		<category><![CDATA[uinavigationitem]]></category>

		<guid isPermaLink="false">http://userflex.wordpress.com/?p=1094</guid>
		<description><![CDATA[An info button is an easy and straightforward way to provide access to a modal view in your application. It&#8217;s especially useful when you want to display something like an about screen but don&#8217;t have a dedicated area for settings. To add one to your iOS app, create a button in the viewDidLoad method of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&amp;blog=2607426&amp;post=1094&amp;subd=userflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>An info button is an easy and straightforward way to provide access to a modal view in your application.</p>
<p>It&#8217;s especially useful when you want to display something like an about screen but don&#8217;t have a dedicated area for settings.</p>
<p>To add one to your iOS app, create a button in the viewDidLoad method of your view controller and add it to the title bar:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
UIButton *infoButton = [UIButton buttonWithType:<br />
&nbsp;&nbsp;&nbsp;&nbsp;UIButtonTypeInfoLight];<br />
[infoButton addTarget:self action:@selector(showInfo:)<br />
&nbsp;&nbsp;&nbsp;&nbsp;forControlEvents:UIControlEventTouchUpInside];</p>
<p>UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc]<br />
&nbsp;&nbsp;&nbsp;&nbsp;initWithCustomView:infoButton];<br />
self.navigationItem.rightBarButtonItem = rightBarButtonItem;<br />
[rightBarButtonItem release];
</td>
</tr>
</table>
</div>
<p><span><br /></span>In this example I&#8217;ve created an info button with a light background and set it as the right bar button item in the title bar of the view controller.</p>
<p>To finish, we just need to define the showInfo method and display a modal view when users tap the button:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
- (IBAction)showInfo:(id)sender<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (! self.infoViewController)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.infoViewController = [[InfoViewController alloc] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;initWithNibName:NSStringFromClass<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;([InfoViewController class]) bundle:nil];<br />
&nbsp;&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;UINavigationController *infoViewNavController =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[[UINavigationController alloc]<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;initWithRootViewController:self.infoViewController];</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;[self.navigationController presentModalViewController:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;infoViewNavController animated:YES];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[infoViewNavController release];<br />
}
</td>
</tr>
</table>
</div>
<p><span><br /></span>In this example I&#8217;ve declared an instance of my modal view (InfoViewController) in the view controller&#8217;s header file, since the view never changes and doesn&#8217;t need to be recreated each time.</p>
<br />Filed under: <a href='http://userflex.wordpress.com/category/ios/'>iOS</a>, <a href='http://userflex.wordpress.com/category/ios/objective-c/'>Objective-C</a> Tagged: <a href='http://userflex.wordpress.com/tag/button/'>button</a>, <a href='http://userflex.wordpress.com/tag/code/'>code</a>, <a href='http://userflex.wordpress.com/tag/development/'>development</a>, <a href='http://userflex.wordpress.com/tag/info-button/'>info button</a>, <a href='http://userflex.wordpress.com/tag/uinavigationitem/'>uinavigationitem</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/userflex.wordpress.com/1094/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/userflex.wordpress.com/1094/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/userflex.wordpress.com/1094/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/userflex.wordpress.com/1094/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/userflex.wordpress.com/1094/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/userflex.wordpress.com/1094/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/userflex.wordpress.com/1094/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/userflex.wordpress.com/1094/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/userflex.wordpress.com/1094/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/userflex.wordpress.com/1094/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/userflex.wordpress.com/1094/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/userflex.wordpress.com/1094/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/userflex.wordpress.com/1094/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/userflex.wordpress.com/1094/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&amp;blog=2607426&amp;post=1094&amp;subd=userflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://userflex.wordpress.com/2012/01/26/info-button-uinavigationitem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8818c04436c5e8590d842b521c3626d1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">Nick</media:title>
		</media:content>
	</item>
		<item>
		<title>How to Cast Integers as Strings in Objective-C</title>
		<link>http://userflex.wordpress.com/2011/12/01/cast-integers-objective-c/</link>
		<comments>http://userflex.wordpress.com/2011/12/01/cast-integers-objective-c/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 21:00:04 +0000</pubDate>
		<dc:creator>Nick Schneble</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[casting]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[integer]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://userflex.wordpress.com/?p=1066</guid>
		<description><![CDATA[I was going to write a post about how casting integers as strings is easy in Flex and hard in Objective-C, but who am I kidding? It&#8217;s easy in both. In general, you&#8217;ll probably be dealing mostly with ints (primitives) and NSNumber objects in your code: NSNumber *myNumber; int myInt; So how do you cast [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&amp;blog=2607426&amp;post=1066&amp;subd=userflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was <em>going</em> to write a post about how casting integers as strings is easy in Flex and hard in Objective-C, but who am I kidding? It&#8217;s easy in both.</p>
<p>In general, you&#8217;ll probably be dealing mostly with ints (primitives) and NSNumber objects in your code:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
NSNumber *myNumber;<br />
int myInt;
</td>
</tr>
</table>
</div>
<p><span><br /></span>So how do you cast them as strings?</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
<p>NSString *myNumberString = [myNumber stringValue];<br />
NSString *myIntString = [[NSNumber numberWithInt:myInt] stringValue];</p>
</td>
</tr>
</table>
</div>
<p><span><br /></span>Easy, right? The only real trick is you have to convert an int to an NSNumber object before you cast it as a string.</p>
<br />Filed under: <a href='http://userflex.wordpress.com/category/ios/'>iOS</a>, <a href='http://userflex.wordpress.com/category/ios/objective-c/'>Objective-C</a> Tagged: <a href='http://userflex.wordpress.com/tag/casting/'>casting</a>, <a href='http://userflex.wordpress.com/tag/code/'>code</a>, <a href='http://userflex.wordpress.com/tag/development/'>development</a>, <a href='http://userflex.wordpress.com/tag/integer/'>integer</a>, <a href='http://userflex.wordpress.com/tag/string/'>string</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/userflex.wordpress.com/1066/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/userflex.wordpress.com/1066/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/userflex.wordpress.com/1066/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/userflex.wordpress.com/1066/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/userflex.wordpress.com/1066/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/userflex.wordpress.com/1066/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/userflex.wordpress.com/1066/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/userflex.wordpress.com/1066/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/userflex.wordpress.com/1066/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/userflex.wordpress.com/1066/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/userflex.wordpress.com/1066/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/userflex.wordpress.com/1066/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/userflex.wordpress.com/1066/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/userflex.wordpress.com/1066/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&amp;blog=2607426&amp;post=1066&amp;subd=userflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://userflex.wordpress.com/2011/12/01/cast-integers-objective-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8818c04436c5e8590d842b521c3626d1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">Nick</media:title>
		</media:content>
	</item>
		<item>
		<title>How to Perform String Substitutions in Xcode 4</title>
		<link>http://userflex.wordpress.com/2011/11/24/string-substitutions-xcode4/</link>
		<comments>http://userflex.wordpress.com/2011/11/24/string-substitutions-xcode4/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 21:00:07 +0000</pubDate>
		<dc:creator>Nick Schneble</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[localization]]></category>
		<category><![CDATA[substitution]]></category>

		<guid isPermaLink="false">http://userflex.wordpress.com/?p=1035</guid>
		<description><![CDATA[Once you&#8217;ve mastered using localized strings in Xcode 4, you can move on to performing substitutions in those strings. The benefit of this approach is two-fold. Strings values easily calculated at runtime don&#8217;t need to be individually defined, and those same strings can still be localized. For example, let&#8217;s say you have a UITableView, and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&amp;blog=2607426&amp;post=1035&amp;subd=userflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Once you&#8217;ve mastered <a href="http://userflex.wordpress.com/2011/10/20/localized-strings-xcode4/">using localized strings in Xcode 4</a>, you can move on to performing substitutions <em>in</em> those strings.</p>
<p>The benefit of this approach is two-fold. Strings values easily calculated at runtime don&#8217;t need to be individually defined, and those same strings can still be localized.</p>
<p>For example, let&#8217;s say you have a UITableView, and for each cell you want to display its index in the table:</p>
<p style="text-align:center;">
<img src="http://userflex.files.wordpress.com/2011/09/string-substitution.png?w=490&#038;h=260" width="490" height="260" />
</p>
<p>Instead of five individually defined strings, you&#8217;d have a single string in your Localizable.strings file with a placeholder for the table index:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
/*<br />
&nbsp;&nbsp;Localizable.strings<br />
&nbsp;&nbsp;How to Perform String Substitutions in Xcode 4</p>
<p>&nbsp;&nbsp;Created by Miscellanea on 11/24/11.<br />
&nbsp;&nbsp;Copyright 2011 __MyCompanyName__. All rights reserved.<br />
*/</p>
<p>&quot;CellTitle&quot; = &quot;Item #%s&quot;;
</td>
</tr>
</table>
</div>
<p><span><br /></span>Then in your UITableViewController implementation you&#8217;d reference the string and perform a substitution for the table index:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
- (UITableViewCell *)tableView:(UITableView *)tableView<br />
&nbsp;&nbsp;&nbsp;&nbsp;cellForRowAtIndexPath:(NSIndexPath *)indexPath<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;static NSString *CellIdentifier = @&quot;Cell&quot;;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;UITableViewCell *cell = [tableView<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dequeueReusableCellWithIdentifier:CellIdentifier];</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;if (cell == nil)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cell = [[[UITableViewCell alloc]<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;initWithStyle:UITableViewCellStyleSubtitle<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reuseIdentifier:CellIdentifier] autorelease];<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<strong><br />
&nbsp;&nbsp;&nbsp;&nbsp;NSString *itemNumber;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// FIXME: we&apos;ll improve this in a later post!<br />
&nbsp;&nbsp;&nbsp;&nbsp;switch (indexPath.row)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case (0):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;itemNumber = @&quot;1&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case (1):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;itemNumber = @&quot;2&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case (2):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;itemNumber = @&quot;3&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case (3):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;itemNumber = @&quot;4&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case (4):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;itemNumber = @&quot;5&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;[cell.textLabel setText:[NSLocalizedString(@&quot;CellTitle&quot;, @&quot;&quot;)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stringByReplacingOccurrencesOfString:@&quot;%s&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;withString:itemNumber]];<br />
</strong><br />
&nbsp;&nbsp;&nbsp;&nbsp;return cell;<br />
}
</td>
</tr>
</table>
</div>
<p><span><br /></span>This isn&#8217;t limited to numeric substitutions; it&#8217;s especially useful for titles and labels with prefixes, or anywhere a string needs to reflect a dynamic state or view.</p>
<p>In a future post I&#8217;ll explain a much better way to display numbers as strings.</p>
<br />Filed under: <a href='http://userflex.wordpress.com/category/ios/'>iOS</a>, <a href='http://userflex.wordpress.com/category/ios/objective-c/'>Objective-C</a>, <a href='http://userflex.wordpress.com/category/ios/xcode/'>Xcode</a> Tagged: <a href='http://userflex.wordpress.com/tag/code/'>code</a>, <a href='http://userflex.wordpress.com/tag/development/'>development</a>, <a href='http://userflex.wordpress.com/tag/localization/'>localization</a>, <a href='http://userflex.wordpress.com/tag/substitution/'>substitution</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/userflex.wordpress.com/1035/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/userflex.wordpress.com/1035/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/userflex.wordpress.com/1035/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/userflex.wordpress.com/1035/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/userflex.wordpress.com/1035/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/userflex.wordpress.com/1035/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/userflex.wordpress.com/1035/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/userflex.wordpress.com/1035/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/userflex.wordpress.com/1035/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/userflex.wordpress.com/1035/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/userflex.wordpress.com/1035/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/userflex.wordpress.com/1035/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/userflex.wordpress.com/1035/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/userflex.wordpress.com/1035/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&amp;blog=2607426&amp;post=1035&amp;subd=userflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://userflex.wordpress.com/2011/11/24/string-substitutions-xcode4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8818c04436c5e8590d842b521c3626d1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">Nick</media:title>
		</media:content>

		<media:content url="http://userflex.files.wordpress.com/2011/09/string-substitution.png" medium="image" />
	</item>
		<item>
		<title>How to Resize a UILabel Based on Its Text</title>
		<link>http://userflex.wordpress.com/2011/11/17/resize-uilabel-text/</link>
		<comments>http://userflex.wordpress.com/2011/11/17/resize-uilabel-text/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 21:00:10 +0000</pubDate>
		<dc:creator>Nick Schneble</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[uilabel]]></category>

		<guid isPermaLink="false">http://userflex.wordpress.com/?p=1005</guid>
		<description><![CDATA[Similar to resizing a UIView when the orientation changes, it can be useful to have a UILabel automatically resize itself based on its text. For example, let&#8217;s say you have a UILabel with a UITextView below it, and you want the UITextView to stay anchored below the UILabel. Here&#8217;s how you&#8217;d do it: - (void)refreshTextLayout [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&amp;blog=2607426&amp;post=1005&amp;subd=userflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Similar to <a href="http://userflex.wordpress.com/2011/09/22/autoresize-uiview-orientation/">resizing a UIView when the orientation changes</a>, it can be useful to have a UILabel automatically resize itself based on its text.</p>
<p>For example, let&#8217;s say you have a UILabel with a UITextView below it, and you want the UITextView to stay anchored below the UILabel.</p>
<p>Here&#8217;s how you&#8217;d do it:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
- (void)refreshTextLayout<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;CGRect myLabelFrame = [self.myLabel frame];<br />
&nbsp;&nbsp;&nbsp;&nbsp;CGSize myLabelSize = [self.myLabel.text &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sizeWithFont:self.myLabel.font<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;constrainedToSize:CGSizeMake(myLabelFrame.size.width, 9999)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lineBreakMode:UILineBreakModeWordWrap];</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;CGFloat delta = myLabelSize.height &#8211; myLabelFrame.size.height;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;myLabelFrame.size.height = myLabelSize.height;<br />
&nbsp;&nbsp;&nbsp;&nbsp;[self.myLabel setFrame:myLabelFrame];</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;CGRect myTextViewFrame = [self.myTextView frame];<br />
&nbsp;&nbsp;&nbsp;&nbsp;myTextViewFrame.origin.y += delta;<br />
&nbsp;&nbsp;&nbsp;&nbsp;myTextViewFrame.size.height -= delta;<br />
&nbsp;&nbsp;&nbsp;&nbsp;[self.myTextView setFrame:myTextViewFrame];<br />
}
</td>
</tr>
</table>
</div>
<p><span><br /></span>This code measures the size of the text in the UILabel (given its current width) and adjusts the UILabel&#8217;s frame to fit the text. It then updates the UITextView&#8217;s frame to reposition it below the UILabel and adjusts its height to fill the remainder of the view.</p>
<p>So how does this happen automagically?</p>
<p>You simply need to invoke refreshTextLayout in the viewWillAppear and didRotateFromInterfaceOrientation methods in the parent view controller:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
- (void)viewWillAppear:(BOOL)animated<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;[super viewWillAppear:animated];</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;[self refreshTextLayout];<br />
}</p>
<p>- (void)didRotateFromInterfaceOrientation:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(UIInterfaceOrientation)fromInterfaceOrientation<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;[self refreshTextLayout];<br />
} </p>
<p>- (BOOL)shouldAutorotateToInterfaceOrientation:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(UIInterfaceOrientation)interfaceOrientation<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;return YES;<br />
}
</td>
</tr>
</table>
</div>
<p><span><br /></span>If you don&#8217;t need to support multiple device orientations then you can omit the last two methods above.</p>
<br />Filed under: <a href='http://userflex.wordpress.com/category/ios/'>iOS</a>, <a href='http://userflex.wordpress.com/category/ios/objective-c/'>Objective-C</a> Tagged: <a href='http://userflex.wordpress.com/tag/code/'>code</a>, <a href='http://userflex.wordpress.com/tag/development/'>development</a>, <a href='http://userflex.wordpress.com/tag/text/'>text</a>, <a href='http://userflex.wordpress.com/tag/uilabel/'>uilabel</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/userflex.wordpress.com/1005/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/userflex.wordpress.com/1005/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/userflex.wordpress.com/1005/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/userflex.wordpress.com/1005/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/userflex.wordpress.com/1005/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/userflex.wordpress.com/1005/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/userflex.wordpress.com/1005/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/userflex.wordpress.com/1005/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/userflex.wordpress.com/1005/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/userflex.wordpress.com/1005/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/userflex.wordpress.com/1005/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/userflex.wordpress.com/1005/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/userflex.wordpress.com/1005/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/userflex.wordpress.com/1005/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&amp;blog=2607426&amp;post=1005&amp;subd=userflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://userflex.wordpress.com/2011/11/17/resize-uilabel-text/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8818c04436c5e8590d842b521c3626d1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">Nick</media:title>
		</media:content>
	</item>
		<item>
		<title>How to Access Custom Properties in Interface Builder</title>
		<link>http://userflex.wordpress.com/2011/11/10/access-properties-ib/</link>
		<comments>http://userflex.wordpress.com/2011/11/10/access-properties-ib/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 21:00:19 +0000</pubDate>
		<dc:creator>Nick Schneble</dc:creator>
				<category><![CDATA[Interface Builder]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[property]]></category>

		<guid isPermaLink="false">http://userflex.wordpress.com/?p=995</guid>
		<description><![CDATA[It&#8217;s easy to add a property to a UIViewController, but how do you access it from Interface Builder when you&#8217;re done? Let&#8217;s say you have a UILabel and a UITextView. To connect them to objects in IB, you need to add an IBOutlet attribute to each of their @property declarations: // //&#160;&#160;CustomViewController.h //&#160;&#160;App Name // [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&amp;blog=2607426&amp;post=995&amp;subd=userflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s easy to <a href="http://userflex.wordpress.com/2011/11/03/add-property-uiviewcontroller/">add a property to a UIViewController</a>, but how do you access it from Interface Builder when you&#8217;re done?</p>
<p>Let&#8217;s say you have a UILabel and a UITextView. To connect them to objects in IB, you need to add an IBOutlet attribute to each of their @property declarations:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
//<br />
//&nbsp;&nbsp;CustomViewController.h<br />
//&nbsp;&nbsp;App Name<br />
//<br />
//&nbsp;&nbsp;Created by Miscellanea on 11/10/11.<br />
//&nbsp;&nbsp;Copyright 2011 __MyCompanyName__. All rights reserved.<br />
//</p>
<p>#import &lt;UIKit/UIKit.h&gt;</p>
<p>@interface CustomViewController : UIViewController<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;UILabel *myLabel;<br />
&nbsp;&nbsp;&nbsp;&nbsp;UITextView *myTextView;<br />
}</p>
<p>@property (nonatomic, retain) <strong>IBOutlet</strong> UILabel *myLabel;<br />
@property (nonatomic, retain) <strong>IBOutlet</strong> UITextView *myTextView;</p>
<p>@end
</td>
</tr>
</table>
</div>
<p><span><br /></span>Now you can switch to Interface Builder and create the same objects in the corresponding user interface (.xib) file.</p>
<p>To connect them, select each object in IB and open the Connections Inspector. (Command-Option-6 or View &gt; Utilities &gt; Connections Inspector) Under Referencing Outlets, click on the circle to the right of &#8220;New Referencing Outlet&#8221; and drag it to the File&#8217;s Owner. It should draw a blue line as you do this. Then select the appropriate property for each object in the menu that appears.</p>
<p>Afterwards you should see a new connection in Referencing Outlets. That&#8217;s it! Now you can configure the objects in your view controller&#8217;s implementation file.</p>
<br />Filed under: <a href='http://userflex.wordpress.com/category/ios/interface-builder/'>Interface Builder</a>, <a href='http://userflex.wordpress.com/category/ios/'>iOS</a>, <a href='http://userflex.wordpress.com/category/ios/objective-c/'>Objective-C</a> Tagged: <a href='http://userflex.wordpress.com/tag/code/'>code</a>, <a href='http://userflex.wordpress.com/tag/development/'>development</a>, <a href='http://userflex.wordpress.com/tag/property/'>property</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/userflex.wordpress.com/995/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/userflex.wordpress.com/995/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/userflex.wordpress.com/995/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/userflex.wordpress.com/995/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/userflex.wordpress.com/995/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/userflex.wordpress.com/995/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/userflex.wordpress.com/995/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/userflex.wordpress.com/995/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/userflex.wordpress.com/995/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/userflex.wordpress.com/995/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/userflex.wordpress.com/995/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/userflex.wordpress.com/995/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/userflex.wordpress.com/995/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/userflex.wordpress.com/995/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&amp;blog=2607426&amp;post=995&amp;subd=userflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://userflex.wordpress.com/2011/11/10/access-properties-ib/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8818c04436c5e8590d842b521c3626d1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">Nick</media:title>
		</media:content>
	</item>
	</channel>
</rss>
