<?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>iPhone Programming Tutorials &#187; AppStoreMod</title>
	<atom:link href="/author/appstoremod/feed/" rel="self" type="application/rss+xml" />
	<link>http://icodeblog.com</link>
	<description>Conquering the mobile universe</description>
	<lastBuildDate>Tue, 28 Jun 2011 21:44:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>iPhone Coding Snippet – In Application Emailing</title>
		<link>http://icodeblog.com/2009/11/18/iphone-coding-tutorial-in-application-emailing/</link>
		<comments>http://icodeblog.com/2009/11/18/iphone-coding-tutorial-in-application-emailing/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 04:45:07 +0000</pubDate>
		<dc:creator>AppStoreMod</dc:creator>
				<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1488</guid>
		<description><![CDATA[A lot of applications you see have an email button. When you click it then it will leave the application and take you to the Mail application. It can get really annoying leaving the application and then going back in after your done sending the email. This is just a great way to show off your app and make your app look more professional and make it easier on the user by filling in the To and Subject for them.  ...]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-1489 alignleft" src="http://staging.icodeblog.com/wp-content/uploads/2009/11/IMG_00011.png" alt="IMG_0001" width="157" height="235" />A lot of applications you see have an email button. When you click it then it will leave the application and take you to the Mail application. It can get really annoying leaving the application and then going back in after your done sending the email. This is just a great way to show off your app and make your app look more professional and make it easier on the user by filling in the To and Subject for them. They are also able to change the From to whatever email then want you to receive an email from just like you can do in the Mail app. So todays tutorial is gonna show you how to email within your application. We will be using the MessageUI framework and we will also include an attachment in the email. Theres a screenshot to the left of how it will look.<span id="more-1488"></span></p>
<p>So lets get started&#8230;</p>
<p><span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px">1. Create A New View Based Application</span><br />
You can name yours whatever you want, in the tutorial I will be referring it as the NameViewControllers.<br />
<span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px"> </span></p>
<p><span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px">2. Import The Frameworks</span></p>
<p>The first thing we need to do is import the framework. So go to your Frameworks folder in the Files In Pain section on the left. Open the folder and right click one of the frameworks and click &#8220;Reveal In Finder.&#8221; Heres a screenshot on what you should do.</p>
<p><img class="aligncenter size-full wp-image-1491" src="http://staging.icodeblog.com/wp-content/uploads/2009/11/Screen-shot-2009-11-18-at-7.58.04-PM1.png" alt="Screen shot 2009-11-18 at 7.58.04 PM" width="310" height="96" /></p>
<p>Go ahead and look for the &#8220;MessageUI.framework&#8221; and highlight it then drag it into your frameworks folder. Make sure that when you click Add on the thing that makes sure you want to import it that &#8220;Copy items into destination group&#8217;s folder (if needed)&#8221; is not check. Thats a very important step or you will have big time problems and you do this with any frameworks you would ever use in the future.</p>
<p><span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px">3. Implementing The Code</span></p>
<p>Now that we have imported the framework lets get into some coding. So go ahead and jump in the NameViewController.H and make an IBAction for a button. Then copy that code and paste it in the NameViewController.M with curly brackets. Also make sure to add the button in Interface Builder and link it up with a Touch Up Inside method. You guys are at the point to knowing how to hook up actions and dragging stuff into Interface Builder. After that we want to on the top of the NameViewController.h import the framework. So on the top do #import &#8220;MessageUI/MessageUI.h&#8221; and the reason why we do this is because we must import out MessageUI framework to make calls to the associated header files. Now we need to also put in the delegate protocols for this framework. @interface NameViewController: UIViewController do this code &lt;MFMailComposeViewControllerDelegate, UINavigationControllerDelegate&gt;. Heres the code here for the NameViewController.H<span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px"> </span></p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #dd0005"><span style="color: #7d4625">#import </span>&lt;MessageUI/MessageUI.h&gt;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span style="color: #c800a7">@interface</span> MailComposerViewController : UIViewController</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">&lt;MFMailComposeViewControllerDelegate,UINavigationControllerDelegate&gt;  {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #008c00">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #008c00"><span style="color: #000000">-(<span style="color: #c800a7">IBAction</span>)pushEmail;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #c800a7">@end</p>
</blockquote>
<div><span style="font-family: Menlo, 'Times New Roman', 'Bitstream Charter', Times, serif;color: #c800a7"><span style="line-height: normal;font-size: small"><br />
</span></span></div>
<p>Now after your done with the .H jump into the .M viewcontroller. Now in your button action code do this:</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">-(<span style="color: #c800a7">IBAction</span>)pushEmail {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #7b1caf"><span style="color: #000000"><span> </span></span>MFMailComposeViewController<span style="color: #000000"> *mail = [[</span>MFMailComposeViewController<span style="color: #000000"> </span><span style="color: #470086">alloc</span><span style="color: #000000">] </span><span style="color: #470086">init</span><span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #7b1caf"><span style="color: #000000"><span> </span>mail.</span>mailComposeDelegate<span style="color: #000000"> = </span><span style="color: #c800a7">self</span><span style="color: #000000">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #7b1caf"><span style="color: #000000"><span> </span></span><span style="color: #c800a7">if</span><span style="color: #000000"> ([</span>MFMailComposeViewController<span style="color: #000000"> </span><span style="color: #470086">canSendMail</span><span style="color: #000000">]) {</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #008c00"><span style="color: #000000"><span> </span></span>//Setting up the Subject, recipients, and message body.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000"><span> </span>[mail </span>setToRecipients<span style="color: #000000">:[</span><span style="color: #7b1caf">NSArray</span><span style="color: #000000"> </span>arrayWithObjects<span style="color: #000000">:</span><span style="color: #dd0005">@"email@email.com"</span><span style="color: #000000">,</span><span style="color: #c800a7">nil</span><span style="color: #000000">]];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #dd0005"><span style="color: #000000"><span> </span>[mail </span><span style="color: #470086">setSubject</span><span style="color: #000000">:</span>@"Subject of Email"<span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000"><span> </span>[mail </span>setMessageBody<span style="color: #000000">:</span><span style="color: #dd0005">@"Message of email"</span><span style="color: #000000"> </span>isHTML<span style="color: #000000">:</span><span style="color: #c800a7">NO</span><span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #008c00"><span style="color: #000000"><span> </span></span>//Present the mail view controller</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000"><span> </span>[</span><span style="color: #c800a7">self</span><span style="color: #000000"> </span>presentModalViewController<span style="color: #000000">:mail </span>animated<span style="color: #000000">:</span><span style="color: #c800a7">YES</span><span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #008c00"><span style="color: #000000"><span> </span></span>//release the mail</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span> </span>[mail <span style="color: #470086">release</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #008c00">//This is one of the delegate methods that handles success or failure</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #008c00">//and dismisses the mail</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">- (<span style="color: #c800a7">void</span>)mailComposeController:(<span style="color: #7b1caf">MFMailComposeViewController</span>*)controller didFinishWithResult:(<span style="color: #470086">MFMailComposeResult</span>)result error:(<span style="color: #7b1caf">NSError</span>*)error</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000"><span> </span>[</span><span style="color: #c800a7">self</span><span style="color: #000000"> </span>dismissModalViewControllerAnimated<span style="color: #000000">:</span><span style="color: #c800a7">YES</span><span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000"><span> </span></span><span style="color: #c800a7">if</span><span style="color: #000000"> (result == </span>MFMailComposeResultFailed<span style="color: #000000">) {</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000"><span> </span></span><span style="color: #7b1caf">UIAlertView</span><span style="color: #000000"> *alert = [[</span><span style="color: #7b1caf">UIAlertView</span><span style="color: #000000"> </span>alloc<span style="color: #000000">] </span>initWithTitle<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;Message Failed!&#8221;</span><span style="color: #000000"> </span>message<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;Your email has failed to send&#8221;</span><span style="color: #000000"> </span>delegate<span style="color: #000000">:</span><span style="color: #c800a7">self</span><span style="color: #000000"> </span>cancelButtonTitle<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;Dismiss&#8221;</span><span style="color: #000000"> </span>otherButtonTitles<span style="color: #000000">:</span><span style="color: #c800a7">nil</span><span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span> </span>[alert <span style="color: #470086">show</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span> </span>[alert <span style="color: #470086">release</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">}</p>
</blockquote>
<div><span style="font-family: Menlo, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size: small"><span style="line-height: normal"><br />
</span></span></div>
<p>What if we wanted to include an image attachment to the email? Well its quite simple. Just add this to the code right under the part where you set up the Recipient, Subject, and the Message.</p>
<blockquote>
<p style="font: normal normal normal 11px/normal Menlo;margin: 0px"><span style="color: #7b1caf">UIImage</span> *pic = [<span style="color: #7b1caf">UIImage</span> <span style="color: #470086">imageNamed</span>:<span style="color: #dd0005">@"Funny.png"</span>];</p>
<p style="font: normal normal normal 11px/normal Menlo;margin: 0px"><span style="color: #7b1caf">NSData</span> *exportData = <span style="color: #470086">UIImageJPEGRepresentation</span>(pic ,<span style="color: #4100e0">1.0</span>);</p>
<p style="font: normal normal normal 11px/normal Menlo;color: #470086;margin: 0px"><span style="color: #000000">[mail </span>addAttachmentData<span style="color: #000000">:exportData </span>mimeType<span style="color: #000000">:</span><span style="color: #dd0005">@"image/jpeg"</span><span style="color: #000000"> </span>fileName<span style="color: #000000">:</span><span style="color: #dd0005">@"Picture.jpeg"</span><span style="color: #000000">];</span></p>
</blockquote>
<p>Now we are setting up the MailComposer in the first part of the code in the action. Then we call a didFinishWithResult method where we are setting up if the email fails or sends. Also it sets up a Cancel button for you so we have to call the dismiss method so that it works. In the attachment code just edit the imageNamed:@&#8221;" with your images name.That is basically it! The source code is below for the people that just doesn&#8217;t wanna copy and paste or type&#8230; I am just jking with you guys. Happy iCoding!</p>
<p><a href="http://staging.icodeblog.com/wp-content/uploads/2009/11/InApplicationEmailing11.zip">iPhone Tutorial &#8211; In Application Emailing</a></p>
]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/11/18/iphone-coding-tutorial-in-application-emailing/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>iPhone Coding Snippet – Inserting A UITextField In A UIAlertView</title>
		<link>http://icodeblog.com/2009/11/09/iphone-coding-tutorial-inserting-a-uitextfield-in-a-uialertview/</link>
		<comments>http://icodeblog.com/2009/11/09/iphone-coding-tutorial-inserting-a-uitextfield-in-a-uialertview/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 02:46:18 +0000</pubDate>
		<dc:creator>AppStoreMod</dc:creator>
				<category><![CDATA[Articles]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1463</guid>
		<description><![CDATA[This will be a simple tutorial showing you how to put a UITextField in a UIAlertView. This is simple and just a couple lines if code. You will learn CGAffineTransform and coding UITextField programmatically.
Heres a screenshots of what we should get.

So lets go ahead and get started&#8230;
1. Create A New View Based Application
You can name it whatever you want, I am gonna name it TextFieldInAlert.
 
2. Implementing The Code
Jump in the viewcontroller.m or if you called it TextFieldInAlert then TextFieldInAlert.m  ...]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-1473" src="http://staging.icodeblog.com/wp-content/uploads/2009/11/Screen-shot-2009-11-09-at-8.12.11-AM-copy1.png" alt="Screen shot 2009-11-09 at 8.12.11 AM copy" width="200" height="96" />This will be a simple tutorial showing you how to put a UITextField in a UIAlertView. This is simple and just a couple lines if code. You will learn CGAffineTransform and coding UITextField programmatically.<span id="more-1463"></span></p>
<p>Heres a screenshots of what we should get.</p>
<p><img class="size-full wp-image-1472 alignnone" src="http://staging.icodeblog.com/wp-content/uploads/2009/11/Screen-shot-2009-11-09-at-8.12.11-AM1.png" alt="Screen shot 2009-11-09 at 8.12.11 AM" width="260" height="388" /></p>
<p>So lets go ahead and get started&#8230;</p>
<p><span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px">1. Create A New View Based Application</span><br />
<span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px"><span style="color: #000000;font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;letter-spacing: normal;line-height: 19px;font-size: 13px">You can name it whatever you want, I am gonna name it TextFieldInAlert.</span></span><br />
<span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px"> </span></p>
<p><span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px">2. Implementing The Code</span><br />
Jump in the viewcontroller.m or if you called it TextFieldInAlert then TextFieldInAlert.m Now find the -(void)viewDidLoad method. Uncomment it and put this code in there.</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">- (<span style="color: #c800a7">void</span>)viewDidLoad {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000"> [</span><span style="color: #c800a7">super</span><span style="color: #000000"> </span>viewDidLoad<span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #7b1caf">UIAlertView</span><span style="color: #000000"> *alert = [[</span><span style="color: #7b1caf">UIAlertView</span><span style="color: #000000"> </span>alloc<span style="color: #000000">] </span>initWithTitle<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;Enter Name Here&#8221;</span><span style="color: #000000"> </span>message<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;this gets covered!&#8221;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #dd0005"> </span>delegate<span style="color: #000000">:</span><span style="color: #c800a7">self</span><span style="color: #000000"> </span>cancelButtonTitle<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;Dismiss&#8221;</span><span style="color: #000000"> </span>otherButtonTitles<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;OK!&#8221;</span><span style="color: #000000">, </span><span style="color: #c800a7">nil</span><span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span style="color: #7b1caf">UITextField</span> *myTextField = [[<span style="color: #7b1caf">UITextField</span> <span style="color: #470086">alloc</span>] <span style="color: #470086">initWithFrame</span>:<span style="color: #470086">CGRectMake</span>(<span style="color: #4100e0">12</span>, <span style="color: #4100e0">45</span>, <span style="color: #4100e0">260</span>, <span style="color: #4100e0">25</span>)];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000">[myTextField </span>setBackgroundColor<span style="color: #000000">:[</span><span style="color: #7b1caf">UIColor</span><span style="color: #000000"> </span>whiteColor<span style="color: #000000">]];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">addSubview</span>:myTextField];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">show</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">release</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[myTextField <span style="color: #470086">release</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">}</p>
</blockquote>
<p>So we are basically calling a UIAlertView and then we are adding the UITextField programmatically. You might have noticed in the message part of the UIAlertView we put &#8220;this gets covered!&#8221;, if we didn&#8217;t put that sentence then the alerts buttons would go up more and the UITextField will be messed. You can try taking that line out and see what happens. Now Build and Run the app. Now you got the UITextField to be inside the UIAlertView. Now try tapping the UITextField. Uh oh, why is the Keyboard covering the UIAlertView? Well there is just a simple fix to this. We just add two more lines of code and it will fix that. Add this to your code</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #7b1caf">CGAffineTransform</span><span style="color: #000000"> myTransform = </span>CGAffineTransformMakeTranslation<span style="color: #000000">(</span><span style="color: #4100e0">0</span><span style="color: #000000">, </span><span style="color: #4100e0">60</span><span style="color: #000000">);</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">setTransform</span>:myTransform];</p>
</blockquote>
<p>So now your full code should be looking like this.</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #7b1caf">UIAlertView</span><span style="color: #000000"> *alert = [[</span><span style="color: #7b1caf">UIAlertView</span><span style="color: #000000"> </span>alloc<span style="color: #000000">] </span>initWithTitle<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;Enter Name Here&#8221;</span><span style="color: #000000"> </span>message<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;this gets covered!&#8221;</span><span style="color: #000000"> </span>delegate<span style="color: #000000">:</span><span style="color: #c800a7">self</span><span style="color: #000000"> </span>cancelButtonTitle<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;Dismiss&#8221;</span><span style="color: #000000"> </span>otherButtonTitles<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;OK!&#8221;</span><span style="color: #000000">, </span><span style="color: #c800a7">nil</span><span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span style="color: #7b1caf">UITextField</span> *myTextField = [[<span style="color: #7b1caf">UITextField</span> <span style="color: #470086">alloc</span>] <span style="color: #470086">initWithFrame</span>:<span style="color: #470086">CGRectMake</span>(<span style="color: #4100e0">12</span>, <span style="color: #4100e0">45</span>, <span style="color: #4100e0">260</span>, <span style="color: #4100e0">25</span>)];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #7b1caf">CGAffineTransform</span><span style="color: #000000"> myTransform = </span>CGAffineTransformMakeTranslation<span style="color: #000000">(</span><span style="color: #4100e0">0</span><span style="color: #000000">, </span><span style="color: #4100e0">60</span><span style="color: #000000">);</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">setTransform</span>:myTransform];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000">[myTextField </span>setBackgroundColor<span style="color: #000000">:[</span><span style="color: #7b1caf">UIColor</span><span style="color: #000000"> </span>whiteColor<span style="color: #000000">]];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">addSubview</span>:myTextField];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">show</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">release</span>];</p>
<p style="font: normal normal normal 11px/normal Menlo;margin: 0px">[myTextField <span style="color: #470086">release</span>];</p>
</blockquote>
<p>Now if you Build and Run, you will notice the UITextField is a little higher and when you tap the UITextField the Keyboard doesn&#8217;t cover it up anymore. That is what the CGAffineTransform was for. So that is basically it! There is a video tutorial also available and if you like video tutorial more then written ones you can check it out out by clicking <a href="http://www.youtube.com/watch?v=1BvuD6MAPmU">HERE</a>. You can download the source code below. Happy iCoding!</p>
<p><a href="http://xcode.appstoremod.com/TextFieldInAlert.zip">iPhone Tutorial &#8211; UITextField In A UIAlertView</a></p>
]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/11/09/iphone-coding-tutorial-inserting-a-uitextfield-in-a-uialertview/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
	</channel>
</rss>
