UITableView didSelectRowAtIndexPath не вызывается при первом касании

У меня проблема с UITableView didSelectRowAtIndexPath для ios 5, что верно для ios 4.

Когда я впервые нажимаю любую строку в таблице, метод не вызывается . Как только я выбираю другую строку, она вызывает didSelectRowAtIndexPath, но передаю последний indexPath.

Я уже установил tableView.delegate, и он может корректно работать в ios4.

MainView.xib
UITabBarController
     --UINavigationController
         --**UITableViewController**

Есть предложения?

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.textLabel.text = [[NSString alloc]initWithFormat:@"%d",indexPath.row];
    return cell;
}

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"%d",indexPath.row);
}
27
задан JOM 31 January 2013 в 09:23
поделиться