Answer the question
In order to leave comments, you need to log in
How to pass a parameter through segue?
You need to pass the cell index to the tableview via segue.
Or how to save it in a singleton.
How?
Answer the question
In order to leave comments, you need to log in
To begin with, we redefine the following function for tableView and initialize the needValue variable (which we will pass), after which the performSegueWithIdentifier method: programmatically make the transition to the next viewController
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
needValue = idexPath.row; //Инициализируем номер ячейки
[tableView deselectRowAtIndexPath:indexPath animated:true]; //Убираем select с ячейки, что бы при возвращении она не была выбрана
[self performSegueWithIdentifier:@"schoolsToLogin" sender:nil]; //Инициализируем переход
}
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"yourSegue"]) //Проверяем тот ли это segue, который нам нужен
{
nextViewController *nextController = (nextViewController *)segue.destinationViewController; //Создаем ссылку на viewController который будет вызван в результате segue
[nextController setNeedValue: _needValue]; //инициализируем значение нужного viewController
}
}
if you use UITableViewController, then it has a property clearsSelectionOnViewWillAppear
and you won't have to manually deselect it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question