IOS Storyboards

  • View

  • Download

Embed Size (px)


Storyboarding is an exciting new feature in iOS 5 that will save you a lot of time building user interfaces for your apps. With a storyboard you have a better conceptual overview of all the screens in your app and the connections between them.

Text of IOS Storyboards

  • 1.IOS Story boardsPresented byMuhammad Nabeel Arif

2. What is Storyboard Storyboarding is an exciting newfeature in iOS 5 that will save you a lotof time building user interfaces foryour apps. 3. Advantages Of Storyboards With a storyboard you have a betterconceptual overview of all the screens inyour app and the connections betweenthem. The storyboard describes the transitionsbetween the various screens. Storyboards make working with tableviews a lot easier with the new prototypecells and static cells features. Can also use .xibs if needed withstoryboards. 4. Disadvantages of Storyboards You also need a bigmonitor, especially when you writeiPad apps! it is only available in iOS 5 onward Like IB, not very friendly with otherdisplay engines and toolkits Merges can be very difficult if notimpossible if there are conflicts. 5. Creating Storyboard ProjectFire up Xcode and create a new project. Product Name: Ratings Company Identifier: the identifier that youuse for your apps, in reverse domainnotation Class Prefix: leave this empty Device Family: iPhone Use Storyboard: check this Use Automatic Reference Counting:check this 6. Creating Storyboard Project 7. In info.plist file, storyboard apps use the keyUIMainStoryboardFile, or Main storyboard file base name, tospecify the name of the storyboard that must be loaded when theapp starts. 8. Incorporate Storyboard inExisting app Open Existing Project, File >New > File > User Interface>Storyboard UIStoryboard *storybrd =[UIStoryboardstoryboardWithName:@"LTDStoryboardIPhone" bundle:nil];AllProspectsNavigationController *navpd = [storybrdinstantiateViewControllerWithIdentifier:@"AllProspectsNavigationController"]; navpd.tabBarItem.title =@"Prospects"; 9. Storyboard Segues A segue is a transition from one view toanother. E.g Select the + button and ctrl-drag to thenew Navigation Controller: 10. Life Cycle of a Segue The destination controller is created and initialized. The segue object is created and itsinitWithIdentifier:source:destination: method is called.The identifier is the unique string you provided for thesegue in Interface Builder, and the two otherparameters represent the two controller objects in thetransition. The source view controllers prepareForSegue:sender:method is called. See Configuring the DestinationController When a Segue is Triggered. The segue objects perform method is called. Thismethod performs a transition to bring the destinationview controller on-screen. The reference to the segue object is released, causingit to be deallocated. 11. Release the mouse button and a smallpopup menu shows up: 12. Manually initiating Segue If you want to perform atransition on somecondition, you can fire asegue manually fromcode. [selfperformSegueWithIdentifier:@"loadMyDetailView"sender:self]; 13. Implementing a Custom Segue To implement a custom segue, yousubclass UIStoryboardSegue andimplement the two methods describedearlier: If you override theinitWithIdentifier:source:destination: method,call the superclasss implementation, theninitialize your subclass. Your perform method must make whateverview controller calls are necessary to performthe transition you want. Typically, you useany of the standard ways to display a newview controller, but you can embellish thisdesign with animations and other effects. 14. Unwinding Storyboard Segues Unwind segues canallow transitioning toexisting instances ofscenes in astoryboard You musthave, higher up inthe view controllerhierarchy, a methodthat is: Marked as IBAction Takes one parameterthat is aUIStoryboardSegue* 15. Prototype cells Prototype cells are one of the cooladvantages that storyboards offer overregular nibs. 16. Prototype Cells That looks a lot simpler! The only thingyou need to do to get a new cell is: UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:@"PlayerCell"]; 17. Designing Our Own PrototypeCells Using a standard cell style is OK for many apps, but I want toadd an image on the right-hand side of the cell that shows theplayers rating (in stars). Having an image view in that spot isnot supported by the standard cell styles, so well have tomake a custom design. 18. Designing Our Own PrototypeCells 19. Static Cells Static table viewsare ideal insituations where apre-determinednumber of itemsneed to bedisplayed to theuser. The fact thatstatic table viewsdo not need adata sourcemakes them fastand easy toimplement. 20. Passing Data Segues are fired automatically on clickof buttons etc. But you can pass datato destination ViewControllers - (void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender { if ([[segue identifier]isEqualToString:@"ShowNewVC"]) { NextViewController *nextVC = (NextViewController *)[seguedestinationViewController]; nextVC.someProperty = self.myProperty; } } 21.