Re: UITextField in UITableView covered by keyboard
Re: UITextField in UITableView covered by keyboard
- Subject: Re: UITextField in UITableView covered by keyboard
- From: Bob Barnes <email@hidden>
- Date: Sat, 24 Oct 2009 11:24:27 -0700
Greg,
The sample code is Apple's UICatalog and my view controller IS a
subclass of UITableViewController. What's making this so frustrating
is that it should just work according to everything I've read, at
least in 3.0+. There are some subtle differences between my code and
the sample though since I have a tab bar and navigation bar. Also,
I've noticed that when debugging UICatalog the tableView instance has
an instance variable _keyboardSupport set, but my tableView doesn't.
This appears to be package private and I haven't located any
documentation about it, but I'm definitely suspicious that it's
related in some way.
I've tried using the UIKeyboardWillShowNotification/
UIKeyboardWillHideNotification notifications, and in fact, use it
successfully in another view, but I didn't look at using contentInset.
I'm convinced that this is a bug in the SDK and I'll try to put
together a test case to submit to Apple when I get some time.
Bob
On Oct 24, 2009, at 9:04 AM, Greg Reichow wrote:
Hi all,
I posted this a yesterday, but it never appeared on the list and
it's not showing up in the web archive so I thought I'd retry.
I have a UITableView that contains some cells with UITextField's
embedded in them. When I touch the UITextField to begin editing the
keyboard pops up and obscures the the text field. I've been looking
at the UICatalog sample, which has a nearly identical setup and
the UITextField scrolls up to make itself visible, but I've been
unable to determine what it's doing to cause that. I've read
suggestions on scrolling the UITexField rect, resizing the
UITableView, etc., but UICatalog doesn't do any of that, yet still
works. What am I missing?
If your view controller is a subclass of UITableViewController, I
believe that it will do the scrolling automatically. (This may
explain why the example code did not show anything to make this
work; yet, I am not sure sure which specific example you were
looking at.)
Otherwise, I have used the contentInset property on the UITableView
to adjust for the keyboard size (which you get from the
UIKeyboardWillShowNotification), and then when the textfield starts
editing, tell the tableview to scroll to that cell with the
textfield. (scrollToRowAtIndexPath:atScrollPosition)
When the keyboard goes away (again the notification will tell you
this), you need to undo the change made to the contentInset
Greg
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden