Remove blank space under UITableView - ios

I have regular UITableView with UISearchDisplayController in Navigation Controller. SizeToFit works on viewDidLoad normally, without any problems. But when i enter search a write some letters, it returns me items, that OK but size of tableview fails.
It is scrolling well, from the bottom to the top but when i reach last item, it stops in middle (it looks like 1 or 2 cells are missing but they are not) & HorizontalScrollIndicator also reach just the middle of tableview.
Any advice ?

It's possible that after you've provided some search parameters and manipulated your data source, you are missing a call for
[self.tableView reloadData];
Hard to tell without the code, but the tableView may be attempting to display rows that should not exist anymore - causing an error in cellForRowAtIndexPath

Related

Accessibility focus goes in space in between the cells in a table view

I am using a table view to show my data. There is no separator view in between the cells but when I switch on the voice over, the focus after on the cell, goes in the space between the two cells ans then on another swipe goes to the next cell.
I am not able to figure out what's going wrong.
The tableView is being imported from another framework, where it is working fine.
The separatorStyle for tableView is set to none.
I just figured out the problem.
In the framework where tableView is populated, array.filter{ !$0.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty } was missing at one place where the tableView was passed with the array as data.
so, that focus was on cells with empty spaces as data.
Thank you

iOS infinite scroll items disapearing (sometimes)

This is a very rare occurring bug from hell,
I have an infinite scroll controller that displays products, 2 in each row. Rarely, something affects the controller and causes items to vanish, when I tap the empty area where the item should be, it works as expected and directs the user to the item details controller. When I back out back to the list, sometimes the cell shows its content, and others get hidden.
Sometimes it just a couple of items missing, sometimes there are so many missing items that makes the list appear empty, like only 1 or 2 cells are visible per screen height.
An even stranger situation is, when I scroll really fast to the end and stretch the screen really fast out of the visible area, and there are no more items to load, the visible items can jump from left to right.
Please see these two videos.
https://www.dropbox.com/s/jibflcouz1ena8n/missingProductImages.mov?dl=0
https://www.dropbox.com/s/uz13fzorypnp38t/again.mov?dl=0
I could send code but I didn't want to clutter this place with full length code, let me know if you want to see a specific section of the code please. Maybe someone could have an idea of what might be going on by looking at the vids.
What's probably going on here is a state problem with your collection view cells. The code assigning model values to the cell's views would be of use here. But absent any actual information, the first thing to review would be the cell's prepareForReuse implementation:
Does it call super?
Does it clear out all current values?
Does it cancel any pending asynchronous operations?
Are fetches and cancellations correctly matched?
Next, check if there's any essential configuration in the cell's init/initWithCoder methods -- those are only called on first creation, not on reuse.
Those are the normal pitfalls of UICollectionView cell handling. If they don't suggest the problem, please post the cell code.
It looks like your cells are not being reused correctly.
Can you check that you have set the same reuseIdentifier for your cell in Interface Builder that you are assigning in your code?
Update: Attached image to show where to set the identifier in the storyboard/xib
Update: added layout solution
Another problem could be due to the layout bounds of your collectionViewCell. When you load your cells they bounds are not calculated until they have been added to your collectionView and rendered. This can cause the elements in your cell to layout with the wrong values. This happens commonly with async image frameworks as they cache a resized version of the image for performance. When you cell loads, the cached image is loaded at the wrong the wrong size.
Add the following code to your collectionViewCell:
- (void)setBounds:(CGRect)bounds {
[super setBounds:bounds];
self.contentView.frame = bounds;
[self setHighlighted:NO];
}

UITableView dynamic cells with a UITextField GCed?

I have a UITableView in which I create my own Cells by adding UIViews to the cell based on the index which is needed as I have about 15 very different cells in one table.
This all works fine, except when I have a UITextField; when I click on the text field, the application crashes which, what looks like something has been garbage collected and now it's still being used.
To reproduce , you simple make a UITableView with a cellForRowAtIndexPath which returns a Cell view to which you add, in the cellForRowAtIndexPath method a UITextField. When the UITableView appears you will see the text fields (and anything else you might have added to it), but clicking on the text field will crash when it becomes first responder.
I'm probably missing something trivial where it is logical somehow but I cannot find references to it from others (or i'm not searching correctly of course).

how to get all text from uitextfield in uitableview

i have a table view with a UITextField in each cell.the table has 30 lines。
i want to get all values from 30 UITextfield,But it works fine for 10 visible cells. I cant't access any invisible cells. the text returns null. please help me.I am a chese developer
I cant't access any invisible cells. the text returns null.
That's how it is supposed to work since UITableView optimizes its use of cells and only displayed cells are actually existing at any time. (at least, if you are using dequeueReusableCellWithIdentifier: as you will find in most UITableView tutorials).
You should possibly store the text entered by the user in each table row somewhere (in your model?) and then access it from there.
Alternatively, you could avoid using dequeueReusableCellWithIdentifier: but in that case you should manage the set of cells in the table view on your own. (I am not encouraging your to do this, it's just a possibility).

UITableView initial row selection

Maybe I'm missing something obvious, but I'm have a hard time programmatically setting the row selection in a tableView. The goal is to simply have a tableView open with a row already selected. The problem appears to be that I have to wait until the tableView is fully loaded before I can modify the selection.
I've read various strategies such as calling reloadData for the tableView in the viewController's viewWillAppear method, then immediately calling selectRowAtIndexPath for the target row. But when I do that, I get a range exception because the tableView has zero rows at that point. The UITableViewDelegate methods (numberOfRowsInSection, etc.) don't appear to be called immediately in response to reloadData (which makes sense if the table rows are drawn "lazily").
The only way I've been able to get this to work is to call selectRowAtIndexPath after a short delay, but then you can see the tableView scroll the selected row into view.
Surely, there's a better way of doing this?
Well, you can use another strategy. You can create a hidden table view, configure how you want and than show to user. Use the tableview.hidden = YES.

Resources