My question is about put into the cache some tableview's cells.
I would put some cells there to make me able to "dequeue" them when I need.
I know that cells go into the cache automatically when you scroll a tableview, but I would make it manually for all cell and not only for those are not displayed anymore because they were scrolled up or down away fron screen.
greetings
You can maintain different queues by using different cell identifier names.
With iOS 5 and storyboarding, if a cell's contents are pretty much constant, you can configure it as a static cell.
If what you're trying to do goes beyond that, you'll have to explain in more detail why you want to subvert the cell caching mechanism.
Related
I have a collection view that is 100 points wide with a number of cells that are each also 100 points wide. I've got it setup to support scrolling and paging horizontally so the user can flick left and right and each cell occupies the entire collection view frame.
Originally, I had no scrolling and the user would tap each cell to activate something in the app. Now that its a narrow frame where only one cell can be seen at a time I feel that tapping is redundant and the cell should simply be tapped in effect when it comes in view.
Is there a way to trigger an event such as didSelectItemAtIndexPath when a given UICollectionViewCell becomes the one displayed within my collection view's frame?
UICollectionView responds to selectItemAtIndexPath:animated:scrollPosition:.
It also responds to indexPathsForVisibleItems which will be useful to determine where to make the selection.
You also need to decide when to make the selection, probably best after receiving scrollViewDidEndDecelerating: which the delegate inherits from UIScrollViewDelegate).
But it may be even better advice to look at what your code does upon selection and just do that (launched from the same place in code, probably when scrolling is finished), leaving selection out of it.
I see UIScrollView has a method to predict final content offset
scrollViewWillEndDragging:withVelocity:targetContentOffset:
and since UITableView is also a UIScrollView, So I want to use this value to calculate the destination Cell while the view is still scrolling/decelerating
I'm trying to loop through all the data and sum up the section headers, cell heights, section footers until the sum exceeds target Content offset. Would it work or is there a better way to do so?
Thanks in advance, any help is appreciated!
Leo
Don't use that method to predict where your table view will end up and try to guess which cells to load content for. Optimising table scrolling, particularly the loading of images, is a well-known problem. Check out this WWDC Video (developer registration required) and Apple's sample LazyTableImages project. Basically, you start background operations to load your cell contents, and update the cells (if they are still on the screen) once your content is loaded. In the meantime, you show placeholder content.
If you do it the way you intend, you will only ever have the target cells populated,which will look odd as you are scrolling past cells that have never been the target.
I have UITableView with custom looking cells. Now user can scroll past the bottom and see that there are no more rows (cells) and see background. I want to create impression that there are more rows below, but they should not be added to tableview, so when user scrolls down, it bounces back to last useful cell.
TableFooter and subview expands content and user can scroll there (or maybe I was doing it wrong).
Right now I added new empty cells and after any action that may recount contentSize I specifically set contentSize to default setting. But I feel like it's not the right way (although it works). Is there some other way?
I tried searching, but it's hard to explain what I want in few sentences, not to mention in search line.
When you put the cell in edit mode and allow multiple cells to be selected at once, the UITableView shows a checkbox on the left of the cell, like below.
How do I change that image? Changing the cell.editingAccessoryView just adds another accessory to the right, instead of changing the left one.
Apologies for reading the question wrong at first. Best I can find at the moment is the multiSelectCheckmarkColor property on the tableview. This technically isn't what you are asking for... however, if simply changing the color is a sufficient solution for you then you might be interested this option.
The only working solution I know is not using the default editing mode at all.
You can easily add a custom checkbox to your cell and animate the cell to show it when entering editation mode.
I have tableView with a lot of cells. I need to remove cells, which user passes while scrolling the tableView.
cellForRowAtIndexPath is called when user scroll to this cell to perform its content and the question is there similar method to know what cells are out of the screen while scrolling?
Take a look at UITableView's visibleCells method. It'll tell which ones are visible. Then I'm assuming you know how many total cells there are and you can do the logic to work out which ones are not visible.