Reputation: 325
I have a UITableView with multiple cells showing information about places including a small compass arrow pointing towards those places.
For the arrow I have a function which calculates the bearing using the current location and heading and then it iterates through every visible cell of the TableView and rotates the arrows. This function is called whenever the position or heading of the device is changed.
Now I would like to call the function also whenever a new cell is returned and also would like to pass the index of the cell so only this arrow will be calculated for the first time.
If I use - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
the cell is not returned yet...
I could use the viewDidScroll
function and work with the first or last visible cell depending on the scroll direction but then the function would also be called if no new cell get's visible.
Is there any chance to get notified when a cell gets returned and which cell it is?
Upvotes: 0
Views: 91
Reputation: 21536
You could use the tableView:willDisplayCell:forRowAtIndexPath:
delegate method instead. From the docs: "A table view sends this message to its delegate just before it uses cell to draw a row, thereby permitting the delegate to customize the cell object before it is displayed".
Upvotes: 1