I am running the following code in cellForRow that does an on-the-fly date calculation. After seeing some stuttering whilst scrolling, I ran a Time Profiler while replicating the stuttering and determined that this bit of my code is the issue. As far as I am aware, this is the best way to accomplish getting a double for difference in number of days and then converting to number of years? Any suggestions on how to reduce the amount of time this takes to hopefully improve scrolling?
Provide default value and then use a completion handler to detect when the calculation is finished. then use reload rows at indexpath. That will let the user scroll and calculate the value in the background. And once the value is calculated, it will reload the cell to show the final value.
Date Formatters are always a heavy task to perform. If we are performing inside the table view cell then we will face scrolling issue with the table view. Approach for better performances using table view cell + Date formatters is to provide final data values to table view cell subview components. Data decoration should be done prior to assigning values to the table view cell.
Instead of using Dictionary use struct to provide data to cell. While initializing model classes all date formatters work should be done.
Now model class array will be passed to table view to render table.
Related
I currently have a big table (aprox 1000 rows) and about 20 columns. Out of the 20 columns I need one to be refreshed once every 2-3 seconds ( holds elapsed time from the object creation ) , i have tried this by refreshing the whole table every 3 seconds but because of so many rows it is a big performance penalty this whole table refresh.
Anyone seen a way to refresh only one cell / one column in JFace tableviewer ?? I need that one elapsed time column refresh and that's it.
Any help is greatly appreciated.
Thanks
Mircea
I see TableViewer didn't expect to refresh just one cell in a row.
AbstractTableViewer
protected void doUpdateItem(Widget widget, Object element, boolean fullMap)
you need to override the above method. Current implementation refreshes the entire row ( basically invokes LabelProvider on each cell)
you can follow the same implementation but invoke update on specific ViewerCell
The TableViewer's refresh() method is meant to be triggered when the list of objects that represents the model for the rows of your table is changed. If you only need to update the text or image shown in a particular row or cell, you should use the update() method. There are variants of that method to let you update as little or us much as necessary.
I have a UITableView. It loads sets of events at regular time intervals. I want to be able to scrol the table view to see all events. I had inserted latest events at position number zero in a row. So whenever I reload the data, my table view has moved one row down. So the user can't view exactly what he wants to read. So I want to reload the UITableView without moving its scrolling position. How can I do that?
Note that my event text height should be vary based on events.
You can either use UITableView's -scrollToRowAtIndexPath:atScrollPosition:animated: or, probably better, UIScrollView's -setContentOffset:animated:, to reposition the table view. You'll probably just have to note the current offset, calculate the new offset (based on where & how many rows you added), and set it after you update the table.
Is it possible to customize the column of table view.
By default table view contains 1 column, But according to my requirement I want 4 column in table.
Means I want table like we create in MS-word/excel.
Thanks.
http://dewpoint.snagdata.com/2008/10/31/drawing-a-grid-in-a-uitableview/
ad
http://usxue.is-programmer.com/posts/14176.html
will help you
No there is no such method to do that ..... but for sure u can make a subclass of UITableViewCell such that it has 4 parts in it and all parts are seperated by a fine line (a kind of bordered image as background will do the job). You can manage your data accordingly and it may create an illusion of MS-word/excel.
But I am sure you are aware of column and row of UITableView, so you can manage all your data is this format. If you want to represent data in tabular fashion like MS-word/excel you don't have enough space as width on iPhone and If you incorporate a tableView in a scroll view, two scroll will not be user friendly.
So i suggest you to go with TableView's native behaviour for such type of task.
I have some options in an UITableView and want that the user can scroll forever. When the end is reached, I want to append the begginning so the user can continue to scroll.
How would I do that?
In tableView:numberOfRowsInSection: return some huge number, and act accordingly in tableView:cellForRowAtIndexPath: by returning same cells over and over.
You can also have limited number of rows, and at the end show a different cell - containing a button for user which he can use to append new rows. When that button is clicked you simply call [tableView reloadData] and provide more rows in table's data source.
Aren't you by any chance misusing the table-view for something it doesn't fit that well ? Maybe you would be better off using just a UIScrollView and reposition subviews as user scrolls over.
I think the only problem is how to trick in the method numberOfRows:. One possible solution is to return some big number here, for example, 10 000. Then, you set up a correct cellForRowAtIndexPath: to return based on your data's number modulo. For example, if you have 100 data entity, then you have to get the indexPath.row % 100
I have a UITableView and its data gets refreshed from a server connection. For the UITableViewcell, I have layout some labels across the row. So it can consider as a grid with UILabels(total no of labels = table rows * table columns).
When the data gets refreshed I have added an animation for the UILabel to highlight the table cell update.(Labels background color changes for about 0.5 seconds and restore to the previous background color). There I compare the old value with new value and I added the animation with comparing those. It works fine.
My problem is when I scroll the table, because of the reusable cells the labels are getting animated.(although the corresponding values are not change). Anyone have an idea to how to avoid this issue? thanks.
It sounds like you're calling reloadData and animating in tableView:cellForRowAtIndexPath:. Don't do this. There's no guarantee that UITableView will reuse the same cell (it sounds like it does, but it's unwise to rely on this, and I'm pretty sure it doesn't for reloadRowsAtIndexPath:withRowAnimation:). It will do the wrong thing if you remove a row, for example.
You can use -[UITableView visibleCells] to get an array of the currently visible cells. Loop over the array and use a custom method to tell each cell to reload with animation.