Estoy teniendo un problema con didSelectRowAtIndexPath de UITableView de iOS 5, que es correcto en iOS 4.UITableView didSelectRowAtIndexPath no ser llamado en primer grifo
La primera vez que pulsa en cualquier fila de la tabla, el método no hace ser llamado. Una vez que selecciono otra fila, ella llama a didSelectRowAtIndexPath, pero pasa el último indexPath.
He establecido ya tableView.delegate, y puede ejecutarse correctamente en ios4.
MainView.xib
UITabBarController
--UINavigationController
--**UITableViewController**
¿Alguna sugerencia?
- (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);
}
¿Se puede publicar el código? ¿Estás seguro de que no has implementado didDeselectRowAtIndexPath en su lugar? – Anna
No implementé deselect. Gracias. –
Esto debería funcionar sin problemas. ¿Esta clase es una subclase de UITableViewController? Si es así, no hay necesidad de establecer delegar en el método viewDidLoad porque ya está asignado. De lo contrario, agregue delegado en el archivo .h de clase entre paréntesis. –