how to get the cell value of a selected cell from Table view in iPhone
Solution 1
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// here we get the cell from the selected row.
UITableViewCell *selectedCell=[tableView cellForRowAtIndexPath:indexPath];
// perform required operation
UIImage * image =selectedCell.image;
// use the image in the next window using view controller instance of that view.
}
Solution 2
You should use UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
indexPath will return you number of section and number of row of selected row.
indexPath.section;
indexPath.row
I hope it was clear. For further understanding you may refer to following tutorials: http://www.edumobile.org/iphone/iphone-programming-tutorials/using-iphone-tableview-for-displaying-data/ http://www.raywenderlich.com/1797/how-to-create-a-simple-iphone-app-tutorial-part-1
Solution 3
In this case I think you should maintain id for each image on the row. It could be your row number, if you have one image per row. Then from
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
you can pass the id to the next view controller. In this view controller you should use this id to get the required data to create your collection view. Hope this helps.
Sabarish
Updated on July 01, 2020Comments
-
Sabarish almost 4 years
Am displaying images in a table view controller where the images are rendered from the URL as XML file. It works well with listing images as scroll view. Now i want to select a particular image and the window should show the selected Cell images alone. For this do i need to get the Cell value. If so how can i get the particular cell value and display its corresponding images as a collection view in next window.
Kindly suggest me an idea. For your better understanding i pasted below an image how my storyboard currently looks and how i need an output.
Hope you understand my problem.