Comment obtenir sélectionné indexPath.section et indexPath.ligne valeur dans UITableView?
J'ai insérer 2 de la section et de 2 lignes de tableview, puis j'ai essayé d'obtenir de la section sélectionnée et la ligne de la valeur à l'aide de UITapGestureRecognizer
, mais je dois obtenir seulement indexPath.section
valeur, je veux à la fois la section de ligne et de valeur. Est-il possible de faire cela? merci de m'aider
Merci d'Avance
J'ai essayé ceci:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
// Add the PatientName Label
UILabel *cellTitle=[[UILabel alloc]initWithFrame:CGRectMake(100, 7, 300, 30)];
cellTitle.userInteractionEnabled = YES;
cellTitle.tag = indexPath.section;
[cellTitle setBackgroundColor:[UIColor clearColor]];
[cellTitle setFont:[UIFont fontWithName:@"Helvetica" size:14]];
[cellTitle setText:[[cellArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]];
[cell.contentView addSubview:cellTitle];
UITapGestureRecognizer *labelTap = [[UITapGestureRecognizer alloc] init];
[labelTap addTarget:self action:@selector(viewPatient:)];
[labelTap setDelegate:nil];
[labelTap setNumberOfTapsRequired:1];
[cellTitle addGestureRecognizer:labelTap]; //cellTitle add here
[labelTap release];
}
-(void)viewPatient:(id)sender
{
UITapGestureRecognizer *lSender = sender;
UILabel *lObjLabel = (UILabel *)[lSender view];
NSLog(@"tag:%d",lObjLabel.tag); //only get indexpath.section value
}
OriginalL'auteur SampathKumar | 2013-06-12
Vous devez vous connecter pour publier un commentaire.
Usage de ce code..
OriginalL'auteur Anand Gautam
écrire cette ligne..
au lieu de
OriginalL'auteur Paras Joshi