<?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: How to Dismiss the Keyboard when using a UITextView</title>
	<atom:link href="http://iPhoneDeveloperTips.com/cocoa/how-to-dismiss-the-keyboard-when-using-a-uitextview.html/feed" rel="self" type="application/rss+xml" />
	<link>http://iPhoneDeveloperTips.com/cocoa/how-to-dismiss-the-keyboard-when-using-a-uitextview.html</link>
	<description>Tips and Tricks for iPhone developers</description>
	<lastBuildDate>Wed, 08 Sep 2010 06:15:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Hai Tran</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-dismiss-the-keyboard-when-using-a-uitextview.html/comment-page-1#comment-22602</link>
		<dc:creator>Hai Tran</dc:creator>
		<pubDate>Fri, 06 Aug 2010 07:59:23 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=741#comment-22602</guid>
		<description>This works very well for me and requires view little coding

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
	NSLog(@&quot;User touched&quot;);
	UITouch *touch = [touches anyObject];
	
	if ([textView isFirstResponder] &amp;&amp; [touch view] != textView) {
		NSLog(@&quot;The textView is currently being edited, and the user touched outside the text view&quot;);
               [textView resignFirstResponder];
	}
}</description>
		<content:encoded><![CDATA[<p>This works very well for me and requires view little coding</p>
<p>- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {<br />
	NSLog(@&#8221;User touched&#8221;);<br />
	UITouch *touch = [touches anyObject];</p>
<p>	if ([textView isFirstResponder] &amp;&amp; [touch view] != textView) {<br />
		NSLog(@&#8221;The textView is currently being edited, and the user touched outside the text view&#8221;);<br />
               [textView resignFirstResponder];<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Saurabh</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-dismiss-the-keyboard-when-using-a-uitextview.html/comment-page-1#comment-12408</link>
		<dc:creator>Saurabh</dc:creator>
		<pubDate>Thu, 01 Apr 2010 07:38:21 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=741#comment-12408</guid>
		<description>Great work Man.  U deserve kudos . Hoping  2 see  some more code from your side. Thanks a lot !!!!</description>
		<content:encoded><![CDATA[<p>Great work Man.  U deserve kudos . Hoping  2 see  some more code from your side. Thanks a lot !!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sijo</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-dismiss-the-keyboard-when-using-a-uitextview.html/comment-page-1#comment-11871</link>
		<dc:creator>Sijo</dc:creator>
		<pubDate>Thu, 25 Mar 2010 08:35:04 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=741#comment-11871</guid>
		<description>thanks for great tip.helped me a lot</description>
		<content:encoded><![CDATA[<p>thanks for great tip.helped me a lot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mk</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-dismiss-the-keyboard-when-using-a-uitextview.html/comment-page-1#comment-9250</link>
		<dc:creator>Mk</dc:creator>
		<pubDate>Mon, 01 Feb 2010 11:59:18 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=741#comment-9250</guid>
		<description>This is how i did it and it works just fine,

- First register for keyboradDidShow notification(in viewDidLoad):
- have a button show up right above the end of the keyboard when the keyboard is shown(implemented in the notification)
- add target to that button so that it discards the keyboard by sending the resignFirstResponder message to the text view.
- also remove the button from the super view in the target method and it looks like the button is showing up with the keyboard. cheers.

- (void)viewDidLoad 
{
	[[NSNotificationCenter defaultCenter] addObserver:self  selector:@selector (keyboardDidShow:)  name: UIKeyboardDidShowNotification object:nil];

....
}


-(void) keyboardDidShow: (NSNotification *)notif 
{
	NSLog(@&quot;keyboard did show&quot;);	
	hideKeyboardButton = [UIButton buttonWithType: UIButtonTypeCustom];
	hideKeyboardButton.frame = CGRectMake(250, 173, 70, 30);
	[hideKeyboardButton setTitle:@&quot;Cancel&quot; forState: UIControlStateNormal];
	[hideKeyboardButton setBackgroundImage:[UIImage imageNamed:@&quot;button.png&quot;] forState: UIControlStateNormal];
	[hideKeyboardButton addTarget: self  action:@selector(hideKeyboard) forControlEvents: UIControlEventTouchUpInside];
	[self.view addSubview:   hideKeyboardButton]; 
}

-(void) hideKeyboard 
{
	[hideKeyboardButton removeFromSuperview];
	[yourTextView resignFirstResponder]; 
}</description>
		<content:encoded><![CDATA[<p>This is how i did it and it works just fine,</p>
<p>- First register for keyboradDidShow notification(in viewDidLoad):<br />
- have a button show up right above the end of the keyboard when the keyboard is shown(implemented in the notification)<br />
- add target to that button so that it discards the keyboard by sending the resignFirstResponder message to the text view.<br />
- also remove the button from the super view in the target method and it looks like the button is showing up with the keyboard. cheers.</p>
<p>- (void)viewDidLoad<br />
{<br />
	[[NSNotificationCenter defaultCenter] addObserver:self  selector:@selector (keyboardDidShow:)  name: UIKeyboardDidShowNotification object:nil];</p>
<p>&#8230;.<br />
}</p>
<p>-(void) keyboardDidShow: (NSNotification *)notif<br />
{<br />
	NSLog(@&#8221;keyboard did show&#8221;);<br />
	hideKeyboardButton = [UIButton buttonWithType: UIButtonTypeCustom];<br />
	hideKeyboardButton.frame = CGRectMake(250, 173, 70, 30);<br />
	[hideKeyboardButton setTitle:@"Cancel" forState: UIControlStateNormal];<br />
	[hideKeyboardButton setBackgroundImage:[UIImage imageNamed:@"button.png"] forState: UIControlStateNormal];<br />
	[hideKeyboardButton addTarget: self  action:@selector(hideKeyboard) forControlEvents: UIControlEventTouchUpInside];<br />
	[self.view addSubview:   hideKeyboardButton];<br />
}</p>
<p>-(void) hideKeyboard<br />
{<br />
	[hideKeyboardButton removeFromSuperview];<br />
	[yourTextView resignFirstResponder];<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mishkin Berteig</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-dismiss-the-keyboard-when-using-a-uitextview.html/comment-page-1#comment-8382</link>
		<dc:creator>Mishkin Berteig</dc:creator>
		<pubDate>Sun, 03 Jan 2010 17:46:11 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=741#comment-8382</guid>
		<description>Thanks very much for this trick.  I&#039;ve been searching and searching for how to get the keyboard to dismiss on the &quot;Done&quot; button.  This seems like a bit of a hack, but at the same time, it allows for the most flexibility of behavior so I can see why it doesn&#039;t automatically dismiss.

Thanks again!</description>
		<content:encoded><![CDATA[<p>Thanks very much for this trick.  I&#8217;ve been searching and searching for how to get the keyboard to dismiss on the &#8220;Done&#8221; button.  This seems like a bit of a hack, but at the same time, it allows for the most flexibility of behavior so I can see why it doesn&#8217;t automatically dismiss.</p>
<p>Thanks again!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zane</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-dismiss-the-keyboard-when-using-a-uitextview.html/comment-page-1#comment-8310</link>
		<dc:creator>zane</dc:creator>
		<pubDate>Thu, 31 Dec 2009 22:55:21 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=741#comment-8310</guid>
		<description>Right on thanks soo much!  Worked like a charm.</description>
		<content:encoded><![CDATA[<p>Right on thanks soo much!  Worked like a charm.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anon</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-dismiss-the-keyboard-when-using-a-uitextview.html/comment-page-1#comment-5790</link>
		<dc:creator>anon</dc:creator>
		<pubDate>Sat, 17 Oct 2009 15:35:52 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=741#comment-5790</guid>
		<description>Thank you so much for this tip!  Very useful!</description>
		<content:encoded><![CDATA[<p>Thank you so much for this tip!  Very useful!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cole</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-dismiss-the-keyboard-when-using-a-uitextview.html/comment-page-1#comment-5518</link>
		<dc:creator>cole</dc:creator>
		<pubDate>Tue, 06 Oct 2009 16:59:01 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=741#comment-5518</guid>
		<description>To answer my own question...this worked: 

// Save the users comment
- (void)textViewDidEndEditing:(UITextView *)textView{
	
	NSLog(@&quot;textView.text: %@&quot;, textView.text);
	
}


Just be sure you have implemented the UITextViewDelegate protocol in your .h file.</description>
		<content:encoded><![CDATA[<p>To answer my own question&#8230;this worked: </p>
<p>// Save the users comment<br />
- (void)textViewDidEndEditing:(UITextView *)textView{</p>
<p>	NSLog(@&#8221;textView.text: %@&#8221;, textView.text);</p>
<p>}</p>
<p>Just be sure you have implemented the UITextViewDelegate protocol in your .h file.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cole</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-dismiss-the-keyboard-when-using-a-uitextview.html/comment-page-1#comment-5516</link>
		<dc:creator>cole</dc:creator>
		<pubDate>Tue, 06 Oct 2009 16:30:22 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=741#comment-5516</guid>
		<description>Anyone know of good method and/or spot that can be used to save the text if/when the UITextView&#039;s keyboard is dismissed?</description>
		<content:encoded><![CDATA[<p>Anyone know of good method and/or spot that can be used to save the text if/when the UITextView&#8217;s keyboard is dismissed?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: marcoyukon</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-dismiss-the-keyboard-when-using-a-uitextview.html/comment-page-1#comment-5318</link>
		<dc:creator>marcoyukon</dc:creator>
		<pubDate>Mon, 28 Sep 2009 20:18:02 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=741#comment-5318</guid>
		<description>Be sure to include the UITextViewDelegate protocol after the UIViewController  subclass interface header file.</description>
		<content:encoded><![CDATA[<p>Be sure to include the UITextViewDelegate protocol after the UIViewController  subclass interface header file.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
