Reputation: 931
I have a static UITableView and I want one of my cells to pop up a dialog box when it is clicked.
I have the code for a popup, and I am using the following method to do things on cell select
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
How can I determine that it's the cell that I want, e.g. test the cell identifier? I'm worried about going by position in case I add a new item to my table, although I know I can do this
int row=indexPath.row;
int section=indexPath.section;
I'm using storyboarding with IOS6.
Upvotes: 0
Views: 526
Reputation: 931
I think the answer by Michal would work with a little extra work on my part.
I actually changed the app so that the cell just loaded another tableview because I decided it was better to separate that functionality out.
Creating a push segue from a static table is easy with storyboarding, just right click the cell and drag to the desired view.
Upvotes: 0
Reputation: 15669
If what you have is table with multiple sections, I suggest defining your own method for counting
- (int)getGlobalRowFor:(int)row at:(int)section {
if(section == 0) {
return row;
} else {
int count = 0;
for(int i = 0; i < section; i++) {
count += [[[self.sections objectAtIndex:i] objectForKey:@"sectionCount"] intValue];
}
return count + row;
}
}
Which tells you where it is in the globel aspect. Other than that you just need to ask you view where it is positioned on screen and you should be good to go!
Upvotes: 1
Reputation: 1948
You need find the unique property of that cell, for example, the position, the text, or the image etc.
If no unique property, u can set the tag property a unique value when create it.
Upvotes: 0