iOS: UITableView -> DetailView init with data
-
29-06-2021 - |
Вопрос
whats the best way, to init a DetailView from a TableView with data?
I need to "send" a object to fill all the labels and ImageViews.
My Code for changing the view:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.navigationController pushViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"detailView"] animated:true];
}
Maik
Решение
Just take the ViewController instantiated from the storyboard and set it up before you push the ViewController
YourViewControllerclass * vc = (YourViewControllerclass*) [self.storyboard instantiateViewControllerWithIdentifier:@"detailView"];
[vc setupMethodForObject: object];
[self.navigationController pushViewController:vc animated:YES];
Другие советы
DetailViewController *viewController = (DetailViewController*) [self.storyboard instantiateViewControllerWithIdentifier:@"detailView"];
viewController.myProperty1 = object1;
viewController.myProperty2 = object2;
[self.navigationController pushViewController:viewController animated:YES];
Не связан с StackOverflow