J'ai un UIViewController
appelé FriendsViewController
à l'intérieur d'un UINavigationController
. Et une deuxième UIViewController
appelé FriendsDetailedViewController
. Lorsque je navigue du premier contrôleur de vue au second, je veux appuyer de manière programmatique sur le bouton Back
lorsque cela est nécessaire. Comment faire ?
Réponse
Trop de publicités?
Mohit
Points
91
1) Lorsque vous faites apparaître le NavigationController actuel, alors
En Swift
self.navigationController?.popViewControllerAnimated(true)
Objectif C
[self.navigationController popViewControllerAnimated:YES];
2) Lorsque vous retournez un autre contrôleur de navigation Puis
En Swift
let story = UIStoryboard(name: "Main", bundle: nil)
let pushVC = story.instantiateViewControllerWithIdentifier("PushVC")
let navigation = story.instantiateViewControllerWithIdentifier("homeNavigation") as! UINavigationController
navigation.pushViewController(pushVC!, animated: true)
En Objective C
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"storyBoardName" bundle:nil];
pushVC* ObjectOfPushVC = [storyboard instantiateViewControllerWithIdentifier:@"pushVC"];
[self.navigationController pushViewController:ObjectOfPushVC animated:YES];
- Réponses précédentes
- Plus de réponses
0 votes
Peut-être voulez-vous simplement revenir à la vue précédente ?