I am using a UITableViewController with static cells, as a user details form. Everything works, until I tap in one of the cells's text field, the keyboard (or custom inputView) shows up, and you scroll the table down. Cells are then not shown, instead a blank space is shown. Scrolling up and back down then correctly shows them.
If I scroll the tableview down until the "geboortedatum" field shows up,
and press on that textfield, a custom inputView with a date picker shows up:
Now, if I scroll the tableview down, the next rows show up blank:
Two rows are supposed to show up there, like this:
It's not related to the inputView with the date picker, the same happens when the plain old keyboard shows up and you scroll the table down.
I have not overridden any of the tableview delegate or datasource methods apart from showing custom headers (but the problem is the same when I remove that), and am not using UITableViewCell subclasses, just static cells in a storyboard. It seems like an iOS bug to me, but is there any way to work around this?
I think I found the cause and the solution. The problem is that these last 2 cells don't actually fit in the storyboard design:
They are there of course, just not visible by default. If I change the storyboard to freeform with a custom height to make it all fit, like this:
Then the problem doesn't show up anymore. The cells are not hidden anymore on scroll, as before. Very strange.
Related
Assume we have UITableView holding a large number of custom UITableViewCells which contain UITextFields and/or UITextViews.
We randomly tab on any cell an the text control inside becomes the FirstResponder. The keyboard appears and we can type some text. Everything is fine.
Is there any reliable information on what happens with the TextField when the cell is re-used for another cell?
In tableView.cellForRowAt:indexPath the cells are dequeued using dequeueReusableCell. Is it my responsibility to keep track on which cell contained the FirstResponder and resign / reset it when the cell is scrolled out of view / back into view as I do for my custom view model?
I ran different test and it seems that this is handled automatically somehow. However, I would like to be sure. Could be coincidence that I did not ran into any problems in my tests.
I have a tableview controller as my initial view. I added some text into it and it's not appearing. First i added some labels, and none of them was appearing, i thought maybe it was a constraint problem. So i added constraints and still didn't work. Then I made the cells basic rather then custom. In basic, it gives you text for you. And still the text isn't appearing. How can i fix this?
Note: This is a new project, I have tested this on a real device and have the same issue.
The table is created with the default prototypes of cells (Content field is Dynamics Prototypes) that need to create and add from the code. If you want to make a static cell, you need to do this in storyboard:
Select TableView
Set Content field in Attributes Inspector to Static Cells
Add your labels to Static cells
For a custom widget, I want to display a list of items in the modal slide-up way that you get from setting a view as the inputView on a widget (that is, it replaces the keyboard for that widget).
I can do this with no issue, but when I set a UITableView as the inputView, it seems to think it is taller than it is. I can scroll all the way past the bottom so that the last item is not even displayed. When there are fewer items than fill the area it adds blank rows way past the bottom of the visible area as well.
Is there something about the inputView area that causes stuff to not know how tall its container is? Is there a workaround?
So, instead of using a UITableViewController, we wrapped it (in the storyboard) in a normal UIViewController with a table view in it, and that seems to be working fine.
I use a UITableView inside a popover in my iPad app to ask for user input, just like the Contacts app on the iPhone. It has 3 sections, and each section has multiple rows. Clicking on a row brings up a keyboard. When clicking on the bottom row of the bottom section, the keyboard hides the row, and when I scroll the table up, it bounces back down instead of staying scrolled up. On the iPhone Contacts app, the table stays scrolled up, and this is the behavior I want. Any pointers?
It's probably because you are not resizing your table view when the keyboard appears. You should take a look here http://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html.
The section "Moving Content That Is Located Under the Keyboard" is what you are looking for.
For your information, a UITableViewController automatically resizes its table view when there is in-line editing of text fields. If it's possible for you, you can just change your class to a UITableViewController and you won't have to worry about resizing.
I have two Scenes in my Storyboard that are nearly identical. Both are UITableViewControllers. Both have header and footer views. The header views have a UISearchBar and the footer views have a UIView that contains a UITextField. Each have only one prototype cell. One is prototyped as a "Basic" cell and the other is prototyped as "Right Detail" cell.
Here's the problem. When I click the UITextField in the footer view on the first scene, the table resizes automatically so that the bottom of the table is at the top of the keyboard. This allows me to scroll the table up so the footer view shows and the user is able to see what they're typing. The other scene will not automatically resize the UITableView so the UITableView cannot scroll the footer view to where it can be seen and the UITextField is hidden under the keyboard. I can't even manually scroll the table far enough since the footer is always at the bottom of the UITableView.
A little added info. The scene that works has many rows of data while the one that doesn't work only has a couple. I tried adding a number of rows until the table had enough to enable scrolling and it doesn't fix the problem.
I have checked everything I can think of and I can't see anything that would allow one of the views to let the UITableView to automatically resize to work with the keyboard and the other not. I must have overlooked something but I can't seem to find it.
Any help will be greatly appreciated!
Rob
I thought this problem was caused by copy-and-pasting from one view to another, but I had the same problem once I'd (in theory) fixed it.
The answer for me turned out to be simple: I hadn't called [super viewWillAppear:animated] in my UITableViewController subclass' viewWillAppear: implementation. Make sure you've got a call to the superclass' method and hopefully the problem will go away.
I am guessing the frame of the tableview is not being resized to the smaller size in the second case.
Print out the frame and content sizes in both the cases once its loaded, that should help you see if there is an issue.