1. Transition de
NIBs/XIBs
vers Storyboards
Jean-Marc LACOSTE - Ambre Systems
Formateur/Consultant
Développeur iOS/UNIX/Linux
Administrateur Système Unix/Linux/MacOSX
Formation et Services
Présentation - Décembre 2012
3. Les NIBs/XIBs
• Habitude de programmation bien maîtrisée
• Généralement 1 NIB/XIB = 1 View
Controller
• Transition manuelles (dans le code)
• nib2objc (Adrian Kosmaczewski)
Jean-Marc LACOSTE - Ambre Systems
4. Les Storyboards
• Vue naturelle du Storyboard «papier»
• Meilleure vision des transitions
• Adapter et porter le code
• Nouvelles habitudes et méthodes
• Possibilité de mélanger storyboards et XIBs
• Incompatibilité avec iOS4- (< 20% parc)
• Travail en groupe plus «délicat»
Jean-Marc LACOSTE - Ambre Systems
5. Poser un nouveau
Storyboard
• Dans un projet «Empty Application»
• Ajouter une nouvelle Resource >
Storyboard
• Lier la ressource à l’appareil
• Contrôler le fichier plist
• Modifier le didFinishLaunchingWithOptions:
Jean-Marc LACOSTE - Ambre Systems
6. Structure d’un
Storyboard
Scène
Attributs
de la Segue
Dock Segue
Jean-Marc LACOSTE - Ambre Systems
7. Segue
• Emprunté à l’Italien segue qui signifie suit
(...)
http://fr.wiktionary.org/wiki/segue
• Le segue est une transition possédant ses
propres attributs
Jean-Marc LACOSTE - Ambre Systems
8. Transition modale
simple
• Segue de type modal
• Obligation de faire le
retour
«manuellement» (par
code) :-(
• Sauf avec du Curl :-)
Jean-Marc LACOSTE - Ambre Systems
11. Mécanismes de
navigation
• Navigation Controller
• TabBar Controller
• TabBar + Navigation
• SplitView Controller
• TabBar + SplitView
• etc.
Jean-Marc LACOSTE - Ambre Systems
12. Démos
• Exemples rapides de construction dans un
storyboard
Jean-Marc LACOSTE - Ambre Systems
13. Custom Segue
• Spécifier une transition
personnalisée
Jean-Marc LACOSTE - Ambre Systems
14. Segue et TableView
• Remplacer didSelectRowAtIndexPath: par
prepareForSegue: comme «déclencheur»
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"Choix %@ se trouvant à l'index %d",
[liste1 objectAtIndex:indexPath.row], indexPath.row);
DetailViewController_iPhone *viewController =
[[DetailViewController_iPhone alloc] init];
[self.navigationController pushViewController:viewController animated:YES];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"versDetail"]) {
NSIndexPath *selectedRowIndex =
[self.tableView1 indexPathForSelectedRow];
DetailViewController_iPhone *viewController =
[segue destinationViewController];
viewController.leChoix = str;
}
}
Jean-Marc LACOSTE - Ambre Systems
15. Segue et TableView
• Modification de
transition
• Utilisation des
identifiants de segue
• Changer ses habitudes
Jean-Marc LACOSTE - Ambre Systems
16. Unwind segue et
passage arrière
• Passage arrière par delegate
• Passage arrière par unwind segue
• Démo
Jean-Marc LACOSTE - Ambre Systems
17. Questions ?
• Exemples et pdfs disponibles sur http://
jeanmarc.lacoste.free.fr/sb/sb.pdf
• Mail
jeanmarc.lacoste@ambre-systems.com
Jean-Marc LACOSTE - Ambre Systems