<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7741342596043848857</id><updated>2024-09-22T21:53:44.350+01:00</updated><category term="your second iOS app"/><category term="becomeFirstResponder"/><category term="disable done button"/><category term="done button"/><category term="enable done button"/><category term="navbar done button"/><category term="scroll to row"/><category term="scrollToRowAtIndexPath"/><category term="table view"/><category term="textFieldShouldReturn"/><category term="when becomes first responder"/><title type='text'>iOS Answers</title><subtitle type='html'>Simple answers to simple problems</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://iosanswers.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7741342596043848857/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://iosanswers.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11037330037361160069</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7741342596043848857.post-2879312240123314149</id><published>2012-02-13T08:38:00.001+00:00</published><updated>2012-02-13T14:35:08.412+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="disable done button"/><category scheme="http://www.blogger.com/atom/ns#" term="done button"/><category scheme="http://www.blogger.com/atom/ns#" term="enable done button"/><category scheme="http://www.blogger.com/atom/ns#" term="navbar done button"/><category scheme="http://www.blogger.com/atom/ns#" term="your second iOS app"/><title type='text'>Enable or Disable NavBar Done Button</title><content type='html'>You&#39;ve got your table based form looking just great now. However, the user experience isn’t ideal. For one thing, the Done button is active as soon as the add scene appears; it would be better if it became active after the user taps a key on the keyboard.&lt;br /&gt;
&lt;br /&gt;
In &lt;a href=&quot;http://iosanswers.blogspot.com/2012/02/table-view-forms-scroll-to-selected.html&quot;&gt;my last post&lt;/a&gt;&amp;nbsp;I told you about the&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7131a8; font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7131a8; font-family: Menlo; font-size: 11px;&quot;&gt;UITextFieldDelegate&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7131a8; font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;and the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;textFieldDidEndEditing&amp;nbsp;&lt;/span&gt;delegate function. We&#39;re going to look at the textField delegate again, but before we go on, let&#39;s tidy that up what we did last time a little bit. &lt;a href=&quot;https://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/SecondiOSAppTutorial/NextSteps/NextSteps.html&quot; target=&quot;_blank&quot;&gt;[Remember all this is based on Your second iOS App tutorial.]&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Next... Next... Next....&lt;/b&gt;&lt;br /&gt;
Let&#39;s make the return button &#39;next&#39; for both fields, see the last post if you can&#39;t remember how, so we pass the user backwards and forwards between the two fields. (If you have more than two... you can work it out!) Change the delegate method to this:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
- (&lt;span style=&quot;color: #b50da1;&quot;&gt;BOOL&lt;/span&gt;)textFieldShouldReturn:(&lt;span style=&quot;color: #7131a8;&quot;&gt;UITextField&lt;/span&gt; *)textField&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b50da1;&quot;&gt;if&lt;/span&gt; (textField == &lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #558187;&quot;&gt;birdNameInput&lt;/span&gt;) {&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #558187;&quot;&gt;locationInput&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;becomeFirstResponder&lt;span style=&quot;color: black;&quot;&gt;];&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #14870b; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;// scroll to row!&lt;/div&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7131a8;&quot;&gt;tableView&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;scrollToRowAtIndexPath&lt;span style=&quot;color: black;&quot;&gt;:[&lt;/span&gt;&lt;span style=&quot;color: #7131a8;&quot;&gt;NSIndexPath&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;indexPathForRow&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #3a00d6;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;inSection&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #3a00d6;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;] &lt;/span&gt;atScrollPosition&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;UITableViewScrollPositionBottom&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;animated&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;YES&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;];&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp; } &lt;span style=&quot;color: #b50da1;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #b50da1;&quot;&gt;if&lt;/span&gt; (textField == &lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #558187;&quot;&gt;locationInput&lt;/span&gt;) {&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #558187;&quot;&gt;birdNameInput&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;becomeFirstResponder&lt;span style=&quot;color: black;&quot;&gt;];&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #14870b; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;// scroll to row!&lt;/div&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7131a8;&quot;&gt;tableView&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;scrollToRowAtIndexPath&lt;span style=&quot;color: black;&quot;&gt;:[&lt;/span&gt;&lt;span style=&quot;color: #7131a8;&quot;&gt;NSIndexPath&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;indexPathForRow&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #3a00d6;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;inSection&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #3a00d6;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;] &lt;/span&gt;atScrollPosition&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;UITableViewScrollPositionBottom&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;animated&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;YES&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;];&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #b50da1; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;YES&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
The &#39;else if&#39; statement part is just the reverse of the first part, taking us back to the first row etc. Now, you might find a more efficient way to call all this if you have 3 or more fields. If you do, let us all know!&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Disable Done button when view appears&lt;/b&gt;&lt;br /&gt;
There are a few ways to do this, but in this post I&#39;ll just give you the simplest. I&#39;m assuming you have put a button item in the right side of the navigation item bar.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;Change&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;viewDidLoad&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&amp;nbsp;in the view controller .m file:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
- (&lt;span style=&quot;color: #b50da1;&quot;&gt;void&lt;/span&gt;)viewDidLoad&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; [&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;viewDidLoad&lt;span style=&quot;color: black;&quot;&gt;];&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #7131a8; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;navigationItem&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;rightBarButtonItem&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;enabled&lt;span style=&quot;color: black;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;NO&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color: #14870b;&quot;&gt;// Easy way!!!&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
It works by saying that item is not enabled. This method will always act on the farthest top right nav bar button item. [Again, it was here in the &lt;a href=&quot;https://developer.apple.com/library/ios/#documentation/uikit/reference/UIBarItem_Class/Reference/Reference.html&quot; target=&quot;_blank&quot;&gt;UIBarItem class reference&lt;/a&gt; all along under enabled, although I&#39;d never have got it simply from looking at that...]&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Done button Enabled - Method 1:&lt;/b&gt;&lt;br /&gt;
&lt;i&gt;- After the text field resigns its first responder status...&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
- (&lt;span style=&quot;color: #b50da1;&quot;&gt;void&lt;/span&gt;)textFieldDidEndEditing:(&lt;span style=&quot;color: #7131a8;&quot;&gt;UITextField&lt;/span&gt; *)textField&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
{ &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #14870b; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;// after the text field resigns its first responder status, enable done button...&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #7131a8; display: inline !important; font: normal normal normal 11px/normal Menlo; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;navigationItem&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;rightBarButtonItem&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;enabled&lt;span style=&quot;color: black;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;YES&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;i&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;i&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;i&gt;- After the text field resigns its first responder status &lt;b&gt;and &lt;/b&gt;it has text entered...&lt;/i&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
- (&lt;span style=&quot;color: #b50da1;&quot;&gt;void&lt;/span&gt;)textFieldDidEndEditing:(&lt;span style=&quot;color: #7131a8;&quot;&gt;UITextField&lt;/span&gt; *)textField&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
{ &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;display: inline !important; font: normal normal normal 11px/normal Menlo; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #14870b;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;if&lt;/span&gt; ([textField.&lt;span style=&quot;color: #7131a8;&quot;&gt;text&lt;/span&gt; &lt;span style=&quot;color: #400c80;&quot;&gt;length&lt;/span&gt;] != &lt;span style=&quot;color: #3a00d6;&quot;&gt;0&lt;/span&gt;) {&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times; font-size: small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;i&gt;
&lt;/i&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;i&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;div style=&quot;color: #7131a8; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;navigationItem&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;rightBarButtonItem&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;enabled&lt;span style=&quot;color: black;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;YES&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;display: inline !important; font: normal normal normal 11px/normal Menlo; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;div style=&quot;display: inline !important; font: normal normal normal 11px/normal Menlo; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;div style=&quot;display: inline !important;&quot;&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
}&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;
This &#39;if&#39; statement says that, when the text field resigns its first responder status (focus shifts to next field) if the text field has at least one character in it, enable the button.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Done button Enabled - Method 2:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;i&gt;- Enable the done button &lt;u&gt;only if both&lt;/u&gt;&amp;nbsp;fields have at least one character in them...&lt;/i&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
Ok, I need to confess: this is an edit. The first attempt I wrote about here worked but only sort of. Then I discovered this way of doing things. What a revelation!&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;In the form view controller .h file, create a new action in the&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #b50da1; font-family: Menlo; font-size: 11px;&quot;&gt;@interface&lt;/span&gt;&amp;nbsp;section:&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;- (&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;IBAction&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;)textField:(&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;id&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;)sender;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Go to the Storyboard scene for your &#39;form&#39;.&lt;/li&gt;
&lt;li&gt;Select a text field, then ctr-click. Up should pop a display of connections for the Text Field.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Drag a connection from &#39;Editing Changed&#39; to the View Controller icon as shown:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFKsf8Ot3HZIhPDkCCB3BuCGUfdMKzgyl3JpRAKfvHZLh9XUPcIGkGj2-6F5Ko5N-r6MiMRqAXiAlWtVjoWDtgwtF_g4Zi8bMypdInX-rOM74rEHFSf9wigftwqBdJz4K0Jz_8SA_Erm_S/s1600/drag-to.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFKsf8Ot3HZIhPDkCCB3BuCGUfdMKzgyl3JpRAKfvHZLh9XUPcIGkGj2-6F5Ko5N-r6MiMRqAXiAlWtVjoWDtgwtF_g4Zi8bMypdInX-rOM74rEHFSf9wigftwqBdJz4K0Jz_8SA_Erm_S/s320/drag-to.png&quot; width=&quot;292&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&amp;nbsp;Then select the IBAction textField which you just created, as shown:&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMoMTTW7WhMGKu0ATEQW87rEYmDCRk0gLUICbicw0hZJglBhbA38M-F2FsquXmWeXNuNvNkgh1j7bsD51oR5KoeGOyCN0xGsmorxPpt1fO9nTKYnyEhtefQ_I3qT1Kk0VkpVVdQI055xyk/s1600/select-action.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMoMTTW7WhMGKu0ATEQW87rEYmDCRk0gLUICbicw0hZJglBhbA38M-F2FsquXmWeXNuNvNkgh1j7bsD51oR5KoeGOyCN0xGsmorxPpt1fO9nTKYnyEhtefQ_I3qT1Kk0VkpVVdQI055xyk/s1600/select-action.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Do this for each text field. This hooks up the action code with the interface builder action. When any key presses happen in the text field, each key press will call this action.&lt;/li&gt;
&lt;li&gt;In the view controller .m file, add a brand new function with this code:&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
- (&lt;span style=&quot;color: #b50da1;&quot;&gt;void&lt;/span&gt;)updateDoneButtonStatus:(&lt;span style=&quot;color: #b50da1;&quot;&gt;id&lt;/span&gt;)sender {&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b50da1;&quot;&gt;int&lt;/span&gt; a = [&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #558187;&quot;&gt;birdNameInput&lt;/span&gt;.&lt;span style=&quot;color: #7131a8;&quot;&gt;text&lt;/span&gt; &lt;span style=&quot;color: #400c80;&quot;&gt;length&lt;/span&gt;];&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #b50da1;&quot;&gt;int&lt;/span&gt; b = [&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #558187;&quot;&gt;locationInput&lt;/span&gt;.&lt;span style=&quot;color: #7131a8;&quot;&gt;text&lt;/span&gt; &lt;span style=&quot;color: #400c80;&quot;&gt;length&lt;/span&gt;];&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #b50da1;&quot;&gt;if&lt;/span&gt; ((a != &lt;span style=&quot;color: #3a00d6;&quot;&gt;0&lt;/span&gt;) &amp;amp;&amp;amp; (b != &lt;span style=&quot;color: #3a00d6;&quot;&gt;0&lt;/span&gt;)) {&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #7131a8; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;navigationItem&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;rightBarButtonItem&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;enabled&lt;span style=&quot;color: black;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;YES&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;} &lt;span style=&quot;color: #b50da1;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #b50da1;&quot;&gt;if&lt;/span&gt; ((a == &lt;span style=&quot;color: #3a00d6;&quot;&gt;0&lt;/span&gt;) || (b == &lt;span style=&quot;color: #3a00d6;&quot;&gt;0&lt;/span&gt;))&amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #7131a8; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;navigationItem&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;rightBarButtonItem&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;enabled&lt;span style=&quot;color: black;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;NO&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
}&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: #558187;&quot;&gt;birdNameInput&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: #7131a8;&quot;&gt;text&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: #400c80;&quot;&gt;length&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;]&lt;/span&gt;&amp;nbsp;gets the length of string within the text field every time a key is pressed. I assigned these to&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;a&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;b&lt;/span&gt;&amp;nbsp;to keep the code tidy and easy to read and I used short names because in the scope they are against easy to read and see what they do; and are only accessible within this function action anyway.&amp;nbsp;&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The first part of the &#39;if&#39; statement will only enable the &#39;done&#39; button if both fields have at least one character in them. The second part will disable the button if any fields character count goes back to zero. Using this function makes the code reusable, as you will see in the next step.&lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Change the&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;textFieldDidEndEditing&amp;nbsp;&lt;/span&gt;function, and add the code for the new action as here:&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
- (&lt;span style=&quot;color: #b50da1;&quot;&gt;void&lt;/span&gt;)textFieldDidEndEditing:(&lt;span style=&quot;color: #7131a8;&quot;&gt;UITextField&lt;/span&gt; *)textField&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
{ &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; [&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #558187;&quot;&gt;birdNameInput&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;addTarget&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;action&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;@selector&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(updateDoneButtonStatus:) &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;forControlEvents&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;UIControlEventEditingChanged&lt;span style=&quot;color: black;&quot;&gt;];&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; [&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #558187;&quot;&gt;locationInput&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;addTarget&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;action&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;@selector&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(updateDoneButtonStatus:)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;forControlEvents&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;UIControlEventEditingChanged&lt;span style=&quot;color: black;&quot;&gt;]; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
}&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
- (&lt;span style=&quot;color: #b50da1;&quot;&gt;IBAction&lt;/span&gt;)textField:(&lt;span style=&quot;color: #b50da1;&quot;&gt;id&lt;/span&gt;)sender {&lt;/div&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; [&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #558187;&quot;&gt;birdNameInput&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;addTarget&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;action&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;@selector&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(updateDoneButtonStatus:)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;forControlEvents&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;UIControlEventEditingChanged&lt;span style=&quot;color: black;&quot;&gt;];&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; [&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #558187;&quot;&gt;locationInput&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;addTarget&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;action&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;@selector&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(updateDoneButtonStatus:)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;forControlEvents&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;UIControlEventEditingChanged&lt;span style=&quot;color: black;&quot;&gt;];&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
}&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
Yes, the code in both these functions/actions is exactly the same. This is the body of the IBAction we hooked up at the start of this method. &lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #400c80; font-family: Menlo; font-size: 11px;&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #400c80; font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #400c80; font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;@selector&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #400c80; font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;(updateDoneButtonStatus:)&lt;/span&gt;&lt;/span&gt;&amp;nbsp;selects the function we made just that turns the done button on and off;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #400c80; font-family: Menlo; font-size: 11px;&quot;&gt;forControlEvents&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #400c80; font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #400c80; font-family: Menlo; font-size: 11px;&quot;&gt;UIControlEventEditingChanged&lt;/span&gt;&amp;nbsp;hooks us back to the &#39;Sent Events&#39; connection we made in the Storyboard/interface builder.&lt;br /&gt;
Currently the only way I know is to specify one for each text field we want this to work on, but I&#39;ll be on the look out for more efficient coding methods!&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;And finally...&lt;/b&gt;&lt;br /&gt;
You could use this to refer to the Done button specifically:&lt;br /&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7131a8;&quot;&gt;UIBarButtonItem&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; *donebutton = [[&lt;/span&gt;&lt;span style=&quot;color: #7131a8;&quot;&gt;UIBarButtonItem&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;alloc&lt;span style=&quot;color: black;&quot;&gt;] &lt;/span&gt;initWithBarButtonSystemItem&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;UIBarButtonSystemItemDone&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;target&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;action&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;@selector&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(ondoneButtonPressed)];&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #7131a8; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;navigationItem&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;rightBarButtonItem&lt;span style=&quot;color: black;&quot;&gt; = donebutton;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #14870b; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;//make done button inactive&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp; donebutton.&lt;span style=&quot;color: #7131a8;&quot;&gt;enabled&lt;/span&gt;=&lt;span style=&quot;color: #b50da1;&quot;&gt;NO&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
But that&#39;s enough for now.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iosanswers.blogspot.com/feeds/2879312240123314149/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iosanswers.blogspot.com/2012/02/enable-or-disable-navbar-done-button.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7741342596043848857/posts/default/2879312240123314149'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7741342596043848857/posts/default/2879312240123314149'/><link rel='alternate' type='text/html' href='http://iosanswers.blogspot.com/2012/02/enable-or-disable-navbar-done-button.html' title='Enable or Disable NavBar Done Button'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11037330037361160069</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFKsf8Ot3HZIhPDkCCB3BuCGUfdMKzgyl3JpRAKfvHZLh9XUPcIGkGj2-6F5Ko5N-r6MiMRqAXiAlWtVjoWDtgwtF_g4Zi8bMypdInX-rOM74rEHFSf9wigftwqBdJz4K0Jz_8SA_Erm_S/s72-c/drag-to.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7741342596043848857.post-5712099485697144298</id><published>2012-02-13T06:17:00.001+00:00</published><updated>2012-02-13T06:19:07.785+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="becomeFirstResponder"/><category scheme="http://www.blogger.com/atom/ns#" term="scroll to row"/><category scheme="http://www.blogger.com/atom/ns#" term="scrollToRowAtIndexPath"/><category scheme="http://www.blogger.com/atom/ns#" term="table view"/><category scheme="http://www.blogger.com/atom/ns#" term="textFieldShouldReturn"/><category scheme="http://www.blogger.com/atom/ns#" term="when becomes first responder"/><category scheme="http://www.blogger.com/atom/ns#" term="your second iOS app"/><title type='text'>Table View forms: scroll to a selected text field&#39;s row</title><content type='html'>If, like me, you sometimes completely fail to understand Apple&#39;s Class Reference documentation, then we&#39;re here for each other!&lt;br /&gt;
&lt;br /&gt;
I had reached the end of &quot;Your Second iOS Application&quot; and decided to try to learn new skills by extending it. What better than to have the keyboard appear as soon as you enter a form like table. Then, to press next and it go to the next field. When you are in the next field, scroll the view up so it is visible and usable.&lt;br /&gt;
&lt;br /&gt;
The first two ideas were easy. But the last, scrolling the text field&#39;s row in to view, seemed a simple problem really, but after searching for two hours and coming no where close, I was near to giving up when stumbled up on the solution.&lt;br /&gt;
&lt;br /&gt;
(If you only need to implement the scroll to action, scroll to the &#39;&lt;b&gt;BUT!&#39;&lt;/b&gt; of this post!)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Making the keyboard appear when the View Appears&lt;/b&gt;&lt;br /&gt;
This one is simple. You want the table view controller of your &#39;form&#39; to make the keyboard appear when the view appears.&lt;br /&gt;
&lt;br /&gt;
This example assumes you have textfields in your table view, that they are set up in a nib file or storyboard, and connected as outlets to your code with useful names. In the case of the &quot;Second iOS App&quot; tutorial, this would mean you control dragged from the textfields in the storyboard to create the&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #b50da1; font-family: Menlo; font-size: 11px;&quot;&gt;IBOutlet&lt;/span&gt;&amp;nbsp;code in the&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;AddSightingViewController.h&lt;/span&gt;&amp;nbsp;file, resulting in code like this:&lt;br /&gt;
&lt;div style=&quot;color: #7131a8; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: #b50da1;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b50da1;&quot;&gt;@interface&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; AddSightingViewController : &lt;/span&gt;UITableViewController&lt;span style=&quot;color: black;&quot;&gt; &amp;lt;&lt;/span&gt;UITextFieldDelegate&lt;span style=&quot;color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #b50da1; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
@property&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;weak&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;nonatomic&lt;span style=&quot;color: black;&quot;&gt;) &lt;/span&gt;IBOutlet&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7131a8;&quot;&gt;UITextField&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; *birdNameInput;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #b50da1; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
@property&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;weak&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;nonatomic&lt;span style=&quot;color: black;&quot;&gt;) &lt;/span&gt;IBOutlet&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7131a8;&quot;&gt;UITextField&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; *locationInput;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #b50da1; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
Two things to note, you &lt;b&gt;must &lt;/b&gt;have&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7131a8; font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7131a8; font-family: Menlo; font-size: 11px;&quot;&gt;UITextFieldDelegate&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7131a8; font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;for everything that follows to work.&lt;br /&gt;
&lt;br /&gt;
To make the keyboard appear I used&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #400c80; font-family: Menlo; font-size: 11px;&quot;&gt;becomeFirstResponder&lt;/span&gt;&amp;nbsp;in the &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;viewDidAppear:&amp;nbsp;&lt;/span&gt;set up.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
- (&lt;span style=&quot;color: #b50da1;&quot;&gt;void&lt;/span&gt;)viewDidAppear:(&lt;span style=&quot;color: #b50da1;&quot;&gt;BOOL&lt;/span&gt;)animated&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp; [&lt;span style=&quot;color: #b50da1;&quot;&gt;super&lt;/span&gt; &lt;span style=&quot;color: #400c80;&quot;&gt;viewDidAppear&lt;/span&gt;:animated];&lt;/div&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; [&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #558187;&quot;&gt;birdNameInput&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;becomeFirstResponder&lt;span style=&quot;color: black;&quot;&gt;];&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
[At the moment my first field is &#39;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #558187; font-family: Menlo; font-size: 11px;&quot;&gt;birdNameInput&lt;/span&gt;&#39;, but what if this changes? We will come to that another time.]&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Making &#39;Return&#39; go to the next input field&lt;/b&gt;&lt;br /&gt;
You textfield will have &#39;Return&#39; on the keyboard by default. You can change this in Storyboard by:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Selecting the textfield&lt;/li&gt;
&lt;li&gt;Going to &#39;attributes&#39; (alt-cmd-4)&lt;/li&gt;
&lt;li&gt;In the &#39;Return Key&#39; drop down list, select &#39;Next&#39; or which ever is appropriate.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;Now this is why the&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7131a8; font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7131a8; font-family: Menlo; font-size: 11px;&quot;&gt;UITextFieldDelegate&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7131a8; font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&amp;nbsp;declaration in&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #b50da1; font-family: Menlo; font-size: 11px;&quot;&gt;@interface&lt;/span&gt;&amp;nbsp;was important. It enables us to use the delegate protocol which gives us all sorts of lovely extra functions and customisations. Currently in the tutorial, if you press return in either field they keyboard will be dismissed. It looks like this:&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;br /&gt;
- (&lt;span style=&quot;color: #b50da1;&quot;&gt;BOOL&lt;/span&gt;)textFieldShouldReturn:(&lt;span style=&quot;color: #7131a8;&quot;&gt;UITextField&lt;/span&gt; *)textField&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b50da1;&quot;&gt;if&lt;/span&gt;&amp;nbsp;((textField == &lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #558187;&quot;&gt;birdNameInput&lt;/span&gt;) || (textField ==&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #558187;&quot;&gt;locationInput&lt;/span&gt;) {&lt;/div&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[textField &lt;/span&gt;resignFirstResponder&lt;span style=&quot;color: black;&quot;&gt;];&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp; } &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #14870b; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #b50da1; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;YES&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
}&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;If the textfield is either of them and return is press, dismiss the keyboard. To make our example select the next textfield, we want to use our&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #400c80; font-family: Menlo; font-size: 11px;&quot;&gt;becomeFirstResponder&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&amp;nbsp;method to get to it. Change the if statement:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;br /&gt;
- (&lt;span style=&quot;color: #b50da1;&quot;&gt;BOOL&lt;/span&gt;)textFieldShouldReturn:(&lt;span style=&quot;color: #7131a8;&quot;&gt;UITextField&lt;/span&gt; *)textField&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b50da1;&quot;&gt;if&lt;/span&gt; (textField == &lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #558187;&quot;&gt;birdNameInput&lt;/span&gt;) {&lt;/div&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #558187;&quot;&gt;locationInput&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;becomeFirstResponder&lt;span style=&quot;color: black;&quot;&gt;];&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 13.0px;&quot;&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #14870b; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;// scroll to row!&lt;/div&gt;
&lt;div style=&quot;font: normal normal normal 11px/normal Menlo; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp; } &lt;span style=&quot;color: #b50da1;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #b50da1;&quot;&gt;if&lt;/span&gt; (textField == &lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #558187;&quot;&gt;locationInput&lt;/span&gt;) {&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [textField &lt;span style=&quot;color: #400c80;&quot;&gt;resignFirstResponder&lt;/span&gt;];&lt;/div&gt;
&lt;div style=&quot;font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #b50da1; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;YES&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: 11px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
And return (or whatever you made the button) will go to the next from the first field, and on the last it will dismiss itself. Great.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;BUT! How do I scroll to the row of tableView?&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Obviously for this small example it isn&#39;t an issue in portrait view, but if you are in landscape, the second field is obscured by the keyboard, and you have to scroll the view to see it as you type. A terrible user experience!&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
As I have hinted in the code above, I want to scroll to the row that I have just made &#39;First Responder&#39;. You can look at Apple&#39;s Developer Document if you want. It&#39;s in the &#39;UITableView Class Reference&#39; part &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
under &#39;-scrollToRowAtIndexPath&#39;. &lt;a href=&quot;https://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableView/scrollToRowAtIndexPath:atScrollPosition:animated:&quot; target=&quot;_blank&quot;&gt;Look at it here now if you really want&lt;/a&gt;, but it&#39;s not pretty. Well, not for noobs.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
It turns out the answer is simple. In the tutorial we&#39;ve used a Table View with static Cells, so we know we have one section (section 0) and two rows (Row 0 and row 1). We&#39;ve made the textfield in row 1 the first responder. [In more complex examples you could get this programmatically, but that&#39;s not this post&#39;s point. ] So we can now add this very simple code:&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;color: #14870b; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;// scroll to row!&lt;/div&gt;
&lt;div style=&quot;color: #400c80; font: 11.0px Menlo; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7131a8;&quot;&gt;tableView&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;scrollToRowAtIndexPath&lt;span style=&quot;color: black;&quot;&gt;:[&lt;/span&gt;&lt;span style=&quot;color: #7131a8;&quot;&gt;NSIndexPath&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;indexPathForRow&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #3a00d6;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;inSection&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #3a00d6;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;] &lt;/span&gt;atScrollPosition&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;UITableViewScrollPositionBottom&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;animated&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #b50da1;&quot;&gt;YES&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
When I tap &#39;next&#39;/&#39;return&#39;/whatever(!) the textfield comes magically in to view.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
It works by telling (sending a message if you like) to tableView that it needs to enact the scrollToRow action. You KNOW the index path for the row: 1. So NOW it all &#39;just works&#39;. Now we can understand more fully what the class reference is getting at...!&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #400c80; font-family: Menlo; font-size: 11px;&quot;&gt;UITableViewScrollPosition&amp;nbsp;&lt;/span&gt;accepts a few different options: top, middle or bottom. I used Bottom and it worked great, but experiment with them yourself to see which best fits your needs. Find out more about that here: &lt;a href=&quot;https://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html#//apple_ref/c/tdef/UITableViewScrollPosition&quot; target=&quot;_blank&quot;&gt;&quot;TableViewScrollPosition&quot;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;In Conclusion&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Hopefully seeing some code actually &#39;in action&#39; will help you understand just a little bit more how it all works and comes together. Eventually I suppose I will understand how to read and put these reference documents in to practice, but at the moment they do seem to just make me go cross eyed.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Any comments, additions or corrections etc. are very welcome!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iosanswers.blogspot.com/feeds/5712099485697144298/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iosanswers.blogspot.com/2012/02/table-view-forms-scroll-to-selected.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7741342596043848857/posts/default/5712099485697144298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7741342596043848857/posts/default/5712099485697144298'/><link rel='alternate' type='text/html' href='http://iosanswers.blogspot.com/2012/02/table-view-forms-scroll-to-selected.html' title='Table View forms: scroll to a selected text field&#39;s row'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11037330037361160069</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7741342596043848857.post-6647513362961516016</id><published>2012-02-13T04:56:00.000+00:00</published><updated>2012-02-13T04:56:52.680+00:00</updated><title type='text'>Firstly: I am no expert!</title><content type='html'>This blog is mainly for all the newbies at iOS who get frustrated at all the so called &#39;help&#39; that they find online. You know, the terse one line replies or the &quot;you simply do this...&quot; and leave you still scratching your head.&lt;br /&gt;
&lt;br /&gt;
I started this blog because one night (tonight) I was searching for the answer to a seemingly simple problem.&amp;nbsp;Aren&#39;t they always the case, except you can&#39;t find a simple answer, or even one that helps you?&lt;br /&gt;
&lt;br /&gt;
Tonight&#39;s &#39;little&#39; question ended up having the simplest of answers, but too many &quot;technical&quot; people out there can&#39;t seem to explain simply what I need to learn. So I thought, share what I learn when I learn it, and pass it on. (I did used to be a teacher I suppose!)&lt;br /&gt;
&lt;br /&gt;
But know this, &lt;b&gt;I really am no expert!&lt;/b&gt;&amp;nbsp;I&#39;m probably just like you, a relative newbie to all this. If you are further on than me, or know a better way, then please: share and help each other.&lt;br /&gt;
&lt;br /&gt;
In the mean time, happy iOS programming!</content><link rel='replies' type='application/atom+xml' href='http://iosanswers.blogspot.com/feeds/6647513362961516016/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iosanswers.blogspot.com/2012/02/firstly-i-am-no-expert.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7741342596043848857/posts/default/6647513362961516016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7741342596043848857/posts/default/6647513362961516016'/><link rel='alternate' type='text/html' href='http://iosanswers.blogspot.com/2012/02/firstly-i-am-no-expert.html' title='Firstly: I am no expert!'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11037330037361160069</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>