2013-02-07 5 views
0

J'ai un bouton dans mainView quand je clique sur le bouton mainview (id 1) ses actions pour appeler nextView [secondview have tableView] tableView cellule première ligne sélectionnée ou en surbrillance state.its état est mis à sélectionné.Appuyez sur UIButton et pour appeler son action vue suivante table cellule sélectionnée état sélectionné?

-(IBAction)btnOneClicked:(id)sender 
{ 
    SecondView *nextView = [[SecondView alloc] initWithNibName:@"SecondView" bundle:nil]; 
    [self.navigationController pushViewController:SecondView animated:YES]; 
    NSIndexPath* selectedCellIndexPath= [NSIndexPath indexPathForRow:0 inSection:0]; 
    [nextView tableView:nextView.firstTable didSelectRowAtIndexPath:selectedCellIndexPath]; 
} 

Vous pouvez consulter la méthode d'action de mon bouton. J'ai essayé beaucoup d'options mais sans succès. S'il vous plaît aider à ce sujet.

Répondre

2

tableView:didSelectRowAtIndex: est en fait la méthode déléguée appelée lorsque vous sélectionnez une ligne.

Pour sélectionner la ligne, vous devez appeler

[nextView.firstTable selectRowAtIndexPath:selectedCellIndexPath animated:YES scrollPosition:UITableViewScrollPositionTop] 
+0

Maintenant, ça fonctionne bien merci ... – Ravindhiran

0

Essayez le code ci-dessous

[button_refresh addTarget:<instance where you want to implement the method> action:@selector(refreshContent:) forControlEvents:UIControlEventTouchUpInside]; 

espère que cela vous aidera.

Questions connexes