<?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>Smart Mobility &#187; development</title>
	<atom:link href="http://blog.zentity.com/tag/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.zentity.com</link>
	<description>The official ZENTITY blog</description>
	<lastBuildDate>Sun, 27 Nov 2011 21:13:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>iPhone SDK &#8211; How To Add CheckBox Control</title>
		<link>http://blog.zentity.com/2009/12/iphone-sdk-how-to-add-checkbox-control/</link>
		<comments>http://blog.zentity.com/2009/12/iphone-sdk-how-to-add-checkbox-control/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 12:45:04 +0000</pubDate>
		<dc:creator>nikesh</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[checkbox]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[sdk]]></category>

		<guid isPermaLink="false">http://blog.zentity.com/?p=97</guid>
		<description><![CDATA[This is quite a common requirement to be able to add a custom checkbox control in an iPhone app. In the Interface builder -&#62; Tools -&#62;library there is no CheckBox control while other controls like Label and Text Field are there. Here is how I implemented it. I would be interested in hearing about how [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.zentity.com%2F2009%2F12%2Fiphone-sdk-how-to-add-checkbox-control%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.zentity.com%2F2009%2F12%2Fiphone-sdk-how-to-add-checkbox-control%2F&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This is quite a common requirement to be able to add a custom checkbox control in an iPhone app. In the Interface builder -&gt; Tools -&gt;library there is no CheckBox control while other controls like Label and Text Field are there. Here is how I implemented it. I would be interested in hearing about how others went about doing it.</p>
<p>You can use the UIButton control to make a CheckBox.</p>
<p>In your project, in the resources folder add the images e.g. the ones attached with in this post “checkbox-selected.png” and “checkbox.png”.</p>
<p><img class="alignnone" src="http://www.zentity.com/images/checkbox.png" alt="" width="16" height="16" /> <img class="alignnone" src="http://www.zentity.com/images/checkbox-selected.png" alt="" width="16" height="16" /></p>
<p>Define the members as follows in “CheckBoxViewController.h”</p>
<pre>
<div style="width: 1px;height: 1px">@interface CheckBoxViewController : UIViewController</div>
<div style="width: 1px;height: 1px">{</div>
<div style="width: 1px;height: 1px"><span> </span>BOOL checkboxSelected;</div>
<div style="width: 1px;height: 1px"><span> </span>UIButton *checkBox;</div>
<div style="width: 1px;height: 1px"><span> </span>UILabel *checkBoxLabel;</div>
<div style="width: 1px;height: 1px">}</div>
</pre>
<p>Uncomment the viewDidLoad in “CheckBoxViewController.m” and use the following code.</p>
<pre>- (void)viewDidLoad
{
	[super viewDidLoad];
	checkBox = [[UIButton alloc] initWithFrame:CGRectMake(60, 100, 16, 16)];
	checkBox.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
	checkBox.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
// Image for normal state
	UIImage *newNormalImage = [UIImage imageNamed:@"checkbox.png"];
	[checkBox setBackgroundImage:newNormalImage forState:UIControlStateNormal];
// Image for highlighted state
	UIImage *newHighlightedImage = [UIImage imageNamed:@"checkbox-selected.png"];
	[checkBox setBackgroundImage:newHighlightedImage forState:UIControlStateHighlighted];
// Image for selected state
	UIImage *newSelectedImage = [UIImage imageNamed:@"checkbox-selected.png"];
	[checkBox setBackgroundImage:newSelectedImage forState:UIControlStateSelected];
	[checkBox addTarget:self action:@selector(checkBoxSelect:)forControlEvents:UIControlEventTouchUpInside];
	checkBox.adjustsImageWhenHighlighted = YES;
	[checkBox setBackgroundColor:[UIColor clearColor]];
	[[self view] addSubview:checkBox];
	checkBoxLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 90, 200, 40)];
	[checkBoxLabel setText:@"Check Box"];
	[checkBox setBackgroundColor:[[ self view] backgroundColor]];
	[[self view] addSubview:checkBoxLabel];
}</pre>
<p>And add the following action method</p>
<pre>-(void)checkBoxSelect:(id)sender
{
	if (checkboxSelected == 0)
	{
		[checkBox setSelected:YES];
		[checkBoxLabel setText:@"Check Box - Selected"];
		checkboxSelected = 1;
	}
	else
	{
		[checkBox setSelected:NO];
		[checkBoxLabel setText:@"Check Box"];
		checkboxSelected = 0;
	}
}</pre>
<p>Build and Run the application, this will work as checkbox control.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zentity.com/2009/12/iphone-sdk-how-to-add-checkbox-control/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
