Crystal
Crystal

Reputation: 29448

didSelectRowAtIndexPath selection when a different row is selected

So I've used UITableView many times before but I'm getting some unusual behavior that I'm trying to narrow down. In a UIPopoverController, I present this UITableView. The app is for iPad. the .xib for the UIViewController is an iPhone. The consultant's did that. I'm not sure if they did that just since it's goign to be smaller versus a typical ipad sized .xib.

My viewcontroller subclass implements UITableViewDelegate and UITableViewDataSource from the .h file.

@property (nonatomic, retain) IBOutlet UITableView *TargetTableView;

I checked the .xib, and the File's Owner of the UITableView is my sublcass, the datasource and delegate are also connected in IB.

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {

    if (tableView == _targetTableView) {
        NSUInteger row = [indexPath row];
        NSLog(@"row: %i", row);
    }

For the first time that I have seen, when I select the first row in the tableView, I get nothing logged to the console. The highlighting is there for the first row. Then when I select the next row, I get "row: 0" logged to the console. It seems to only log after I select the next row. I don't know if this is something ppl have seen before and I'm missing something stupid since I've made other UITableViews before w/o problems. Thanks.

Upvotes: 0

Views: 190

Answers (2)

user467105
user467105

Reputation:

You've implemented didDeselectRowAtIndexPath instead of didSelectRowAtIndexPath.

Upvotes: 2

amattn
amattn

Reputation: 10065

You should check and log indexPath.section as well as row.

Upvotes: 0

Related Questions