Tag: didselectrowatindexdexpath

DidSelectRowAtIndexPath使用故事板

在我的应用程序我使用下面的didSelectRowAtIndexPath方法去一个viewController,但我正在一个故事板内工作,并引发exception告诉我,找不到nib文件。 我应该如何改变方法来打开新的viewController没有例外? //link to the next view -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { EmpresasTableViewController *detailViewController = [[EmpresasTableViewController alloc] initWithNibName:@"EmpresasTableViewController" bundle:nil]; detailViewController.title =[[categorias objectAtIndex:indexPath.row]objectForKey:@"idCategoria"]; detailViewController.categoriaDescription = [categorias objectAtIndex:indexPath.row]; [self.navigationController pushViewController:detailViewController animated:YES]; }

UITableViewCell里带有手势识别器的UILabel块didSelectRowAtIndexPath

我在UITableViewCell使用了UITapGestureRecognizer一些UITapGestureRecognizer 。 GestureRecognizer运行良好。 但是当我点击标签时,我希望didSelectRowAtIndexPath:应该执行。 甚至只是indexPathForSelectedRow()方法应该给我选定的行。 设置cancelsTouchesInView = false不起作用! 这可能吗? 现在indexPathForSelectedRow()方法返回nil。 谢谢

故事板segue在UITableView的didSelectRow之前被调用

我有一个从单元格segue故事板。 我想设置一些属性与一些数据,当一行被选中,所以我做了以下几点: – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [[ProperyManager sharedPropertyManager]setSelectedRow:[verseIds objectAtIndex:indexPath.row]]; [[ProperyManager sharedPropertyManager]setID:[poemIDs objectAtIndex:indexPath.row]]; [[ProperyManager sharedPropertyManager]setRowToReturn:[NSString stringWithFormat:@"%i",indexPath.row]]; } 问题是,在上面的didSelectRow方法之前调用目标视图控制器的视图控制器生命周期方法(viewWillAppear等),因为在执行委托方法之前,segue会推送视图。 我怎样才能解决这个问题?

在UITableView的每个部分select一行?

场景: 我在一个UITableView中创build了2个部分,用户需要在每个部分中select一行,如下面的截图所示。 预期结果:1.用户应该能够在每个部分中select一行 结果现在:1.在我select了一个行中的行,然后当我select第二个行中的行时,第一个select消失。 这是我的代码: – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Uncheck the previous checked row long sec=indexPath.section; if(sec==0){ if(self->checkedIndexPath) { UITableViewCell* uncheckCell = [tableView cellForRowAtIndexPath:self->checkedIndexPath]; uncheckCell.accessoryType = UITableViewCellAccessoryNone; } if([self->checkedIndexPath isEqual:indexPath]) { self->checkedIndexPath = nil; } else { UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath]; cell.accessoryType = UITableViewCellAccessoryCheckmark; self->checkedIndexPath = indexPath; }} if(sec==1){ if(self->checkedIndexPath) { […]

在UITableView IOS中select行时,多选checkMark

我有一个UITableView显示选中行时的复选标记。 问题是,当我在didSelectRowAtIndexPathselect一行并在所选行上添加复选标记时,它会添加一个复选标记。 这是我的代码 任何帮助将非常感激。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; // Configure the cell… cell.textLabel.text=[[Model.category objectAtIndex:indexPath.row] categoryName]; cell.imageView.image=[[Model.category objectAtIndex:indexPath.row]categoryImage]; //cell.detailTextLabel.text =@"Breve Descripción de la categoria"; return cell; } – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ if ([self.tableView cellForRowAtIndexPath:indexPath].accessoryType == UITableViewCellAccessoryCheckmark) { [self.tableView cellForRowAtIndexPath:indexPath].accessoryType =UITableViewCellAccessoryNone; [self.cellSelected removeObject:indexPath]; }else { [tableView cellForRowAtIndexPath:indexPath].accessoryType=UITableViewCellAccessoryCheckmark; […]