<?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: Adjust UITextField hidden behind Keyboard with UIScrollView</title>
	<atom:link href="http://www.iphonesampleapps.com/2009/12/adjust-uitextfield-hidden-behind-keyboard-with-uiscrollview/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.iphonesampleapps.com/2009/12/adjust-uitextfield-hidden-behind-keyboard-with-uiscrollview/</link>
	<description>Sample IPhone Apps, Tutorials, Example Code</description>
	<lastBuildDate>Thu, 19 Aug 2010 19:42:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Neil</title>
		<link>http://www.iphonesampleapps.com/2009/12/adjust-uitextfield-hidden-behind-keyboard-with-uiscrollview/comment-page-1/#comment-23</link>
		<dc:creator>Neil</dc:creator>
		<pubDate>Thu, 19 Aug 2010 19:42:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.iphonesampleapps.com/wordpress/?p=1#comment-23</guid>
		<description>Hi, great article!
I too was having an issue with the transition in either way being a bit too harsh so Ive fixed it by animating both scrollRectToVisible and the scrollView frame resize. It&#039;s now very smooth and seamless in both directions!

&lt;code&gt;

- (void)keyboardWillHide:(NSNotification*)notification{

    NSDictionary* userInfo = [notification userInfo];
	
    NSValue* boundsValue = [userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey];
    CGSize keyboardSize = [boundsValue CGRectValue].size;
	
    CGRect viewFrame = self.scrollView.frame;
	
    viewFrame.size.height += (keyboardSize.height);
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationBeginsFromCurrentState:YES];
	[UIView setAnimationDuration:0.3];
	[self.scrollView setFrame:viewFrame];
	[UIView commitAnimations];
	
	CGRect oldFrame=CGRectMake(viewOffset.x, viewOffset.y, viewFrame.size.width , viewFrame.size.height );
	[scrollView scrollRectToVisible:oldFrame animated:YES];

    keyboardIsShown = NO;
}

-(void)keyboardWillShow:(NSNotification*)notification{

    if (keyboardIsShown) {
        return;
    }
	
    NSDictionary* userInfo = [notification userInfo];
	
    // get the size of the keyboard
    NSValue* boundsValue = [userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey];
    CGSize keyboardSize = [boundsValue CGRectValue].size;
	
	viewOffset=scrollView.contentOffset;
    
    CGRect viewFrame = self.scrollView.frame; viewFrame.size.height -= (keyboardSize.height );
	
	[UIView beginAnimations:nil context:NULL];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationDuration:0.3];
    [self.scrollView setFrame:viewFrame];
    [UIView commitAnimations];
	
	
	CGRect textFieldRect = [currentField frame];
    textFieldRect.origin.y += 10;
    [scrollView scrollRectToVisible:textFieldRect animated:YES];
	
	
    keyboardIsShown = YES;
}

&lt;code&gt;

Cheers!</description>
		<content:encoded><![CDATA[<p>Hi, great article!<br />
I too was having an issue with the transition in either way being a bit too harsh so Ive fixed it by animating both scrollRectToVisible and the scrollView frame resize. It&#8217;s now very smooth and seamless in both directions!</p>
<p><code></p>
<p>- (void)keyboardWillHide:(NSNotification*)notification{</p>
<p>    NSDictionary* userInfo = [notification userInfo];</p>
<p>    NSValue* boundsValue = [userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey];<br />
    CGSize keyboardSize = [boundsValue CGRectValue].size;</p>
<p>    CGRect viewFrame = self.scrollView.frame;</p>
<p>    viewFrame.size.height += (keyboardSize.height);<br />
	[UIView beginAnimations:nil context:NULL];<br />
	[UIView setAnimationBeginsFromCurrentState:YES];<br />
	[UIView setAnimationDuration:0.3];<br />
	[self.scrollView setFrame:viewFrame];<br />
	[UIView commitAnimations];</p>
<p>	CGRect oldFrame=CGRectMake(viewOffset.x, viewOffset.y, viewFrame.size.width , viewFrame.size.height );<br />
	[scrollView scrollRectToVisible:oldFrame animated:YES];</p>
<p>    keyboardIsShown = NO;<br />
}</p>
<p>-(void)keyboardWillShow:(NSNotification*)notification{</p>
<p>    if (keyboardIsShown) {<br />
        return;<br />
    }</p>
<p>    NSDictionary* userInfo = [notification userInfo];</p>
<p>    // get the size of the keyboard<br />
    NSValue* boundsValue = [userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey];<br />
    CGSize keyboardSize = [boundsValue CGRectValue].size;</p>
<p>	viewOffset=scrollView.contentOffset;</p>
<p>    CGRect viewFrame = self.scrollView.frame; viewFrame.size.height -= (keyboardSize.height );</p>
<p>	[UIView beginAnimations:nil context:NULL];<br />
    [UIView setAnimationBeginsFromCurrentState:YES];<br />
    [UIView setAnimationDuration:0.3];<br />
    [self.scrollView setFrame:viewFrame];<br />
    [UIView commitAnimations];</p>
<p>	CGRect textFieldRect = [currentField frame];<br />
    textFieldRect.origin.y += 10;<br />
    [scrollView scrollRectToVisible:textFieldRect animated:YES];</p>
<p>    keyboardIsShown = YES;<br />
}</p>
<p></code><code></p>
<p>Cheers!</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BrunoVR</title>
		<link>http://www.iphonesampleapps.com/2009/12/adjust-uitextfield-hidden-behind-keyboard-with-uiscrollview/comment-page-1/#comment-16</link>
		<dc:creator>BrunoVR</dc:creator>
		<pubDate>Sat, 19 Jun 2010 14:43:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.iphonesampleapps.com/wordpress/?p=1#comment-16</guid>
		<description>Ciao !

Thank&#039;s for this tutorial.
I use your method and work very well, but i have a problem, 
I have 3 textfield in my screen,  2 at the bottom and hidden behind the keyboard, and 1 textfield in the upper side.
When i edit the textfield in the upper side , the view scroll up.   
It&#039;s possible to scroll the view ONLY if the textfield is hidden ( &gt; of the keyboard height) 

Thank&#039;s so much !

BrunoVR</description>
		<content:encoded><![CDATA[<p>Ciao !</p>
<p>Thank&#8217;s for this tutorial.<br />
I use your method and work very well, but i have a problem,<br />
I have 3 textfield in my screen,  2 at the bottom and hidden behind the keyboard, and 1 textfield in the upper side.<br />
When i edit the textfield in the upper side , the view scroll up.<br />
It&#8217;s possible to scroll the view ONLY if the textfield is hidden ( &gt; of the keyboard height) </p>
<p>Thank&#8217;s so much !</p>
<p>BrunoVR</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: muanis</title>
		<link>http://www.iphonesampleapps.com/2009/12/adjust-uitextfield-hidden-behind-keyboard-with-uiscrollview/comment-page-1/#comment-13</link>
		<dc:creator>muanis</dc:creator>
		<pubDate>Wed, 09 Jun 2010 01:55:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.iphonesampleapps.com/wordpress/?p=1#comment-13</guid>
		<description>@bhavesh very good point, i&#039;ve found some more info on this approach in this &lt;a href=&quot;http://discussions.apple.com/message.jspa?messageID=8045475&quot; rel=&quot;nofollow&quot;&gt;discussion&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>@bhavesh very good point, i&#8217;ve found some more info on this approach in this <a href="http://discussions.apple.com/message.jspa?messageID=8045475" rel="nofollow">discussion</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: muanis</title>
		<link>http://www.iphonesampleapps.com/2009/12/adjust-uitextfield-hidden-behind-keyboard-with-uiscrollview/comment-page-1/#comment-12</link>
		<dc:creator>muanis</dc:creator>
		<pubDate>Wed, 09 Jun 2010 01:45:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.iphonesampleapps.com/wordpress/?p=1#comment-12</guid>
		<description>@Johndesp I&#039;ve double check the code and it&#039;s the same as the text. Maybe you didn&#039;t notice, that the code in the zipfile is the final version, with the changes that add the activefield attribute. Let me know if I can help you in any way.

muanis</description>
		<content:encoded><![CDATA[<p>@Johndesp I&#8217;ve double check the code and it&#8217;s the same as the text. Maybe you didn&#8217;t notice, that the code in the zipfile is the final version, with the changes that add the activefield attribute. Let me know if I can help you in any way.</p>
<p>muanis</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neel</title>
		<link>http://www.iphonesampleapps.com/2009/12/adjust-uitextfield-hidden-behind-keyboard-with-uiscrollview/comment-page-1/#comment-11</link>
		<dc:creator>Neel</dc:creator>
		<pubDate>Wed, 05 May 2010 22:10:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.iphonesampleapps.com/wordpress/?p=1#comment-11</guid>
		<description>Hey friend,

Thank you so much. your description was very helpful, it really helped me finding solution to my problem. Great article. Thanks a lot.</description>
		<content:encoded><![CDATA[<p>Hey friend,</p>
<p>Thank you so much. your description was very helpful, it really helped me finding solution to my problem. Great article. Thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bhavesh Patel</title>
		<link>http://www.iphonesampleapps.com/2009/12/adjust-uitextfield-hidden-behind-keyboard-with-uiscrollview/comment-page-1/#comment-10</link>
		<dc:creator>Bhavesh Patel</dc:creator>
		<pubDate>Thu, 29 Apr 2010 09:16:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.iphonesampleapps.com/wordpress/?p=1#comment-10</guid>
		<description>This is the simple way to do this 


[objc]
- (void)setViewMovedUp:(BOOL)movedUp
{
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:0.3];
	CGRect rect = self.view.frame;
	rect.origin.y = 0.0;
	
	if (movedUp)
	{
		rect.origin.y -= kOFFSET_FOR_KEYBOARD;
	}
	
	if(!movedUp){
		
		rect.origin.y = 0.0f;
	}
	
	self.view.frame = rect;
	[UIView commitAnimations];
	
}
[/objc]</description>
		<content:encoded><![CDATA[<p>This is the simple way to do this </p>
<pre class="brush: objc;">
- (void)setViewMovedUp:(BOOL)movedUp
{
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:0.3];
	CGRect rect = self.view.frame;
	rect.origin.y = 0.0;

	if (movedUp)
	{
		rect.origin.y -= kOFFSET_FOR_KEYBOARD;
	}

	if(!movedUp){

		rect.origin.y = 0.0f;
	}

	self.view.frame = rect;
	[UIView commitAnimations];

}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: JohnDesp</title>
		<link>http://www.iphonesampleapps.com/2009/12/adjust-uitextfield-hidden-behind-keyboard-with-uiscrollview/comment-page-1/#comment-9</link>
		<dc:creator>JohnDesp</dc:creator>
		<pubDate>Sun, 14 Feb 2010 00:21:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.iphonesampleapps.com/wordpress/?p=1#comment-9</guid>
		<description>Hi. Great article. The link to the source code seem to be do different code.

Can you recheck the link?

thanks

johndesp</description>
		<content:encoded><![CDATA[<p>Hi. Great article. The link to the source code seem to be do different code.</p>
<p>Can you recheck the link?</p>
<p>thanks</p>
<p>johndesp</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: muanis</title>
		<link>http://www.iphonesampleapps.com/2009/12/adjust-uitextfield-hidden-behind-keyboard-with-uiscrollview/comment-page-1/#comment-4</link>
		<dc:creator>muanis</dc:creator>
		<pubDate>Sun, 10 Jan 2010 17:09:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.iphonesampleapps.com/wordpress/?p=1#comment-4</guid>
		<description>Craig, I even tried to come up with an animated version, but then I gave up. If you notice the behavior of apple&#039;s own applications (like Notes for instance) just snaps back also. In my tests I used some basic animations like in &lt;a href=&quot;http://www.switchonthecode.com/tutorials/creating-basic-animations-on-iphone&quot; rel=&quot;nofollow&quot;&gt;this post&lt;/a&gt; but after all, it seems impossible to resize the UIScrollView before the keyboard hides, and then the UITextFields really appear cutted while it resizes.</description>
		<content:encoded><![CDATA[<p>Craig, I even tried to come up with an animated version, but then I gave up. If you notice the behavior of apple&#8217;s own applications (like Notes for instance) just snaps back also. In my tests I used some basic animations like in <a href="http://www.switchonthecode.com/tutorials/creating-basic-animations-on-iphone" rel="nofollow">this post</a> but after all, it seems impossible to resize the UIScrollView before the keyboard hides, and then the UITextFields really appear cutted while it resizes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig</title>
		<link>http://www.iphonesampleapps.com/2009/12/adjust-uitextfield-hidden-behind-keyboard-with-uiscrollview/comment-page-1/#comment-3</link>
		<dc:creator>Craig</dc:creator>
		<pubDate>Sat, 09 Jan 2010 19:44:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.iphonesampleapps.com/wordpress/?p=1#comment-3</guid>
		<description>Great article, this perfectly fixed a problem I was experiencing. Thanks!</description>
		<content:encoded><![CDATA[<p>Great article, this perfectly fixed a problem I was experiencing. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig J. Remy</title>
		<link>http://www.iphonesampleapps.com/2009/12/adjust-uitextfield-hidden-behind-keyboard-with-uiscrollview/comment-page-1/#comment-2</link>
		<dc:creator>Craig J. Remy</dc:creator>
		<pubDate>Sat, 09 Jan 2010 04:40:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.iphonesampleapps.com/wordpress/?p=1#comment-2</guid>
		<description>This is a very useful post. Thank you. One question, how do you animate the UIScrollView back into position. Currently it just snaps back which is not very elegant.</description>
		<content:encoded><![CDATA[<p>This is a very useful post. Thank you. One question, how do you animate the UIScrollView back into position. Currently it just snaps back which is not very elegant.</p>
]]></content:encoded>
	</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! -->
