I want to add the content of the cell of tableview in other view when i click on the tableview cell , how can i pass the values of the cell to other view.
views:
45answers:
2
Q:
how to add the content of the cell of table view in other view when clicked on cell in objective-c
A:
In your table view delegate (by default, it's the table view controller) implement the following method:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
Use indexPath as you did in -tableView:cellForRowAtIndexPath: to get the values you need. To avoid unexpected behavior you should extract the values from your model rather than the cell.
Costique
2010-02-15 08:05:21
+1
A:
If you want use the text of a cellview for example you can do that in your UITableViewDelegate (or your UITableViewController):
// Tells the delegate that the specified row is now deselected.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *targetCell = [tableView cellForRowAtIndexPath:indexPath];
NSString *contentCell = [targetCell textLabel];
// Do something with the contentCell
}
Yannick L.
2010-02-15 09:36:59