I am happily able to set the styling of my tableviewcells using the cellForRowAtIndexPath delegate, but I want to set the background of all the nonpopulated cells which are still on the screen
hey, basically any cell which is part of your tableview belongs to a particular index and particular row
so incase you are not populating a particular section via data source - you can still get a reference to a cell in that indexPath by manually calling the cellForRowAtIndexPath delegate, and passing the section as well as row index
it returns you a cell. assign it to your private variable and edit it the way you want to.
Use the visibleCells method on your table view. Then do what you wish to the cells.
Alternately, you could call indexPathsForVisibleRows to get just the index paths. Then call cellForRowAtIndexPath: to get the cell corresponding to each index path.
Related
I am unable to find a solution for this on my own, please help.
I have a table view with -/+ buttons inside that increase or decrease a value.
In the footer cell of the table is a label for the "total sum", the added value of all the cell values. When the value inside of a cell is decreased or increased, I want the footer cell text to change accordingly.
Any pointers how I go about that? I have tried to write a global function, but then I can't access the label anymore... tried it as a class method (static), but I can't seem to get it to work.
Can I somehow hook up the action that occurs in the UITableViewCell to trigger an action in the UITableView?
Thank you!
In the UITableViewDelegate associated to your table view, you should call the reloadRowsAtIndexPaths(indexPaths: [NSIndexPath], withRowAnimation animation: UITableViewRowAnimation) method to update your the row you wish to update.
Than it your UITableViewDataSource provide the footer cell with the good new value.
I have a tableView of person. every time i pass the mouse over a person row, i want to show some information about it . ( the information can be showed in a textArea for example). Thanx
Can you assign the onMouseEntered property of the TableCell instances in your TableView value?
A custom cell value factory can be used to provide instances of an application-specific cell subclass. This allows the custom cell to assign its own event handling function to the event handling property defined by Node. For example, try this in the custom subclass of TableCell provided by the cell value factory:
onMouseEntered = (event: MouseEvent) => {
info(s"onMouseEntered cell ${index()}: $event")
event.consume()
}
TableCell.index() provides the current index of the cell in the TableView.
If you don't get the value you expect it might be because cells are recycled. If you scroll through a large table the TableView will use a technique called "virtualization" to reuse the cell instances by associating an existing cell with different content, e.g. the first cell that you can see might be the 100th cell in the table.
My data is sourced in a plist and displayed in a tableview with navigation bar.
I want to load the subview with the cell that was clicked.
I know this would set it correct, but I'm not sure how to implement indexPath in the viewDidLoad method?
self.navigationItem.title = [[self.exerciseArray objectAtIndex:indexPath.row]objectForKey: #"name"];
You have an array of Dictionary With you. Now IndexPath is seen called in TableView delegate methods. I doesn't mean that you can't create one. Create an NSIndexpath obect and assign the indexes parameters and send it to the function which contains the above code( separate the code which sets the title from the Cell for row at index path).
But the problem is as I see, You want to show only a specific set of data in dictionary which is stored in an Array. The real problem is You should know which the index of the Array you want to load. to the title and the tableview. If you can know that then its solved.
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/Reference/Reference.html
Regards ,
Jackson Sunny Rodrigues
I have a situation where I want to set the hide the cell if cell.textlabel.text == nil.
I tried using heightForRowAtIndexPath...
But this event is fired before the cellForRowAtIndexPath event and that's why I doesn't get text of the cell.
Is there any way that I can set height of cell to zero if there cell.textlabel.text == nil in cellForRowAtIndexPath event.
You can't set values of TableView - the only way to change its appearance is to tell her to reloadData, and then let delegate feed it with new, fresh ones. You can also use deleteRowsAtIndexPaths:withRowAnimation: to remove a cell, insertRowsAtIndexPaths:withRowAnimation: to insert it back later on.
From what you write I guess you structured your program in a very bad way. You should have a separation between Model, View and Controller.
i have tried to set up a uitableview cell to be given a tag however i am not sure how to get the cell to become tagged on user input (uibutton) and then the code required to retrieve the multiple items or single item tagged.
Well, without understanding exactly what you plan to do, indexPath points to the selected cell.
If you try to keep object references you could move all information you need to an instance variable type NSArray/NSDictionary from cellForRowAtIndexPath.