archive-com.com » COM » T » TECHOTOPIA.COM

Total: 1018

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • Organizing Scenes over Multiple Xcode Storyboard Files - Techotopia
    second button to Scene 2 labelled Go to Scene 3 and establish a modal presentation segue to the newly added scene As before be sure to set the Auto Layout settings to suggested constraints eBookFrenzy com Purchase the full edition of this iOS 9 App Development Essentials book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters To move this new scene to a second storyboard select it in the storyboard and choose the Editor Refactor to Storyboard menu option note that although only a single scene is being exported in this case multiple scenes can also be selected and moved in a single operation Once the menu option is selected a panel Figure 26 2 will appear seeking the name to be given to the new storyboard In the Save As field name the file Second storyboard Figure 26 2 Click on the Save button to save the scene to the new storyboard Once saved two changes will have taken place First a review of the Project Navigator panel will reveal the presence of a new storyboard file named Second storyboard which when selected will reveal that it contains the third scene that was originally located in the Main storyboard file Second a review of the Main storyboard file will reveal that the third scene has now been replaced by a storyboard reference as shown in Figure 26 3 and that the segue is still in place Figure 26 3 Select the Second storyboard reference and display the Attributes Inspector panel Note that the Storyboard property is set to the Second storyboard file and that by default it is configured to display the Initial View Controller within that storyboard which in this case is the only scene within the second storyboard Figure 26 4 Compile and run the app and verify that the Go to Scene 3 button does indeed segue to the third scene Establishing a Connection between Different Storyboards The previous section explored the separation of existing scenes within a storyboard into separate storyboard files Consider however a scenario where a segue needs to be established between two scenes in two different storyboards where no reference has yet been established To see this in action select the File New File menu option and in the resulting panel select User Interface from under the iOS heading and Storyboard from the main panel Click Next and name the file Third storyboard before clicking on Create Select the Third storyboard file from the Project Navigator panel and drag and drop a View Controller instance from the Object Library panel onto the storyboard canvas Add a label to the view and change the text to read Scene 4 before setting appropriate Auto Layout constraints The objective is now to establish a segue from the Go to Scene 4 button in the scene in the Second storyboard file to the new scene in the Third storyboard file

    Original URL path: http://www.techotopia.com/index.php/Organizing_Scenes_over_Multiple_Xcode_Storyboard_Files (2016-02-13)
    Open archived version from archive


  • Using Xcode 7 Storyboards to Create an iOS 9 Tab Bar Application - Techotopia
    named ViewController swift A Main storyboard file has also been created To start with an entirely clean project select the ViewController swift file in the project navigator panel and press the keyboard Delete key to remove the file from the project choosing the option to move the file to the trash when prompted to do so Adding the View Controllers for the Content Views The ultimate goal of this chapter is to create a tab bar based application consisting of two tabs with corresponding views each of these will require a view controller The first step therefore is to add the view controller for the first view To achieve this select the File New File menu option and on the resulting panel select Source from beneath the iOS heading in the left hand panel and Cocoa Touch Class from the list of templates Click Next and on the next screen name the new class Tab1ViewController and change the Subclass of menu to UIViewController Ensure that the Also create XIB file option is switched off before clicking Next Select the desired location for the creation of the class files before clicking on Create Repeat the above steps to add a second view controller class named Tab2ViewController The scene within the storyboard file now needs to be associated with one of these view controller classes Select the Main storyboard file and select the scene added by Xcode so that it is highlighted with a blue border before displaying the Identity Inspector panel View Utilities Show Identity Inspector Within the inspector panel change the Class setting from UIViewController to Tab1ViewController The second view controller may be added to the storyboard simply by dragging and dropping one from the Object Library panel View Utilities Show Object Library onto the storyboard canvas Once it has been added follow the same steps to change the view controller class within the Identity Inspector panel this time selecting Tab2ViewController in the Class field Adding the Tab Bar Controller to the Storyboard As previously explained the navigation between view controllers in a Tab Bar based interface is handled by a Tab Bar Controller It will be necessary therefore to add one of these to our storyboard Begin by selecting the Main storyboard file in the Xcode project navigator panel eBookFrenzy com Purchase the full edition of this iOS 9 App Development Essentials book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters In order to add a Tab Bar Controller to the storyboard select the Tab1ViewController in the storyboard design area and select the Editor Embed In Tab Bar Controller menu option The Tab Bar Controller will subsequently appear in the storyboard already connected to the Tab 1 View Controller as shown in Figure 27 1 Figure 27 1 A relationship now needs to be established between the Tab2ViewController class and the Tab Bar Controller To achieve this simply Ctrl click on the Tab

    Original URL path: http://www.techotopia.com/index.php/Using_Xcode_7_Storyboards_to_Create_an_iOS_9_Tab_Bar_Application (2016-02-13)
    Open archived version from archive

  • Working with the iOS 9 Stack View Class - Techotopia
    stack view are sized Options available are as follows Fill The subviews are resized so as to fill the entire space available along the axis of the stack view In other words the height of the subviews will be modified to fill the full height of the stack view in vertical orientation while the widths will be changed for a stack view in horizontal orientation The amount by which each subview is resized relative to the other views can be controlled via the compression resistance and hugging priorities of the views details of which were covered in the chapter entitled An Introduction to Auto Layout in iOS 9 and the position of the views in the stack view s arrangedSubviews array Figure 31 5 FillEqually The subviews are resized equally to fill the stack view along the view s axis In a vertical stack therefore all of the subviews will be of equal height whilst in a horizontal axis orientation the subviews will be of equal width Figure 31 6 FillProportionally In this mode the subviews are resized proportionally to their intrinsic content size along the axis of the stack view to fill the width or height of the view EqualSpacing Padding is used to space the subviews equally to fill the stack view along the axis The size of the subviews will be reduced if necessary in order to fit within the available space based on the compression resistance priority setting and the position within the arrangedSubviews array Figure 31 7 EqualCentering This mode tries to position the subviews along the stack view s axis such that the views have equal center to center spacing The spacing used in this mode is influenced by the spacing property outlined below Where possible the stack view will honor the prevailing spacing property value but will reduce this value if necessary If the views still do not fit the size of the subviews will be reduced if necessary in order to fit within the available space based on the compression resistance priority setting and the position within the arrangedSubviews array Figure 31 8 spacing The spacing property specifies the distance in points between the edges of adjacent subviews within a stack view When the stack view distribution property is set to FillProportionally the spacing value dictates the spacing between the subviews In EqualSpacing and EqualCentering modes the spacing value indicates the minimum allowed spacing between the adjacent edges of the subviews A negative spacing value causes subviews to overlap eBookFrenzy com Purchase the full edition of this iOS 9 App Development Essentials book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters alignment The alignment property controls the positioning of the subviews perpendicularly to the axis of the stack view Available alignment options are as follows Fill In fill mode the subviews are resized to fill the space perpendicularly to the stack view s axis In other

    Original URL path: http://www.techotopia.com/index.php/Working_with_the_iOS_9_Stack_View_Class (2016-02-13)
    Open archived version from archive

  • An iOS 9 Stack View Tutorial - Techotopia
    row to a stack view this time named Switches 2 Stack View Select the Switches 1 Stack View in the Document Outline panel and using the Attributes Inspector panel change Alignment to Fill and Distribution to Equal Spacing Repeat this step for the Switches 2 Stack View entry Creating the Top Level Stack View The next step is to add the existing stack views to a new vertical stack view To achieve this select all three of the stack views in the storyboard scene and click on the Stack button Within the Document Outline panel locate this new parent stack view and change the name to Top Level Stack View At this point verify that the view outline matches that of Figure 32 10 Figure 32 10 eBookFrenzy com Purchase the full edition of this iOS 9 App Development Essentials book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters With the Top Level Stack View object selected change both the Alignment and Distribution settings to Fill With these changes made the storyboard scene should appear as shown in Figure 32 11 Figure 32 11 Adding the Button Stack View Two Button objects now need to be added to the Top Level Stack View but instead of using the Stack button this time the button stack view and buttons will be added directly to the top level stack With the Main storyboard file selected locate the Horizontal Stack View in the Object Library panel and drag it to the bottom edge of the Top Level Stack View in the storyboard scene so that a bold blue line appears together with a tag that reads Top Level Stack View Figure 32 12 Release the stack view to add it as a subview of the top level stack then use the Document Outline panel to name the stack Button Stack View Drag and drop two Button views from the Object Library onto the new stack view Select the Button Stack View entry in the Document Outline and change the Distribution property to Fill Equally The buttons should now be spread equally over the width of the top level stack view With the left button selected change the text to read Add a Cup and change the background color property in the View section of the Attributes Inspector panel to green Repeat these steps for the right hand button this time setting the text to Remove a Cup and the background color to cyan Display the Assistant Editor panel and establish action connections from the left and right buttons to methods named addCup and removeCup respectively Adding the Final Subviews to the Top Level Stack View Two final subviews now need to be added to the top level stack view to complete the layout From the Object Library panel drag a Date Picker object and drop it immediately above the Switches 1 Stack View in the Document Outline

    Original URL path: http://www.techotopia.com/index.php/An_iOS_9_Stack_View_Tutorial (2016-02-13)
    Open archived version from archive

  • An iOS 9 Split View Master-Detail Example - Techotopia
    To change the title of the master pane locate it within the storyboard canvas double click on the title text which currently reads Master and enter Favorite Web Sites as the new title as outlined in Figure 33 1 Figure 33 1 Configuring Master View Items The master view controller created for us by Xcode is actually a subclass of UITableView The next step therefore is to configure the table view to display the list of web sites For this purpose we will need to configure two array objects to store the web site names and corresponding URL addresses Select the MasterViewController swift file and modify it as follows to declare these two arrays import UIKit class MasterViewController UITableViewController var siteNames String var siteAddresses String var detailViewController DetailViewController nil var objects AnyObject Having declared the arrays modify the MasterViewController swift file further to initialize the arrays in the viewDidLoad method Note that Xcode has already added some code to the viewDidLoad method for the template example so be sure to remove this before adding the new code below override func viewDidLoad super viewDidLoad siteNames Yahoo Google Apple Bing siteAddresses https www yahoo com https www google com https www apple com https www bing com if let split splitViewController let controllers split viewControllers self detailViewController controllers controllers count 1 as UINavigationController topViewController as DetailViewController There are a number of methods that must be implemented in order for the items to appear within the table view object Fortunately Xcode has already placed template methods for us to use in the MasterViewController swift file First modify the numberOfRowsInSection method to notify the table view of the number of items to be displayed in this case a value equal to the number of items in our siteNames array Since there is only one section in the table also modify the numberOfSectionsInTableView method accordingly Note that Xcode has once again added some code for the template example so be sure to remove this code where necessary override func numberOfSectionsInTableView tableView UITableView Int return 1 override func tableView tableView UITableView numberOfRowsInSection section Int Int return siteNames count eBookFrenzy com Purchase the full edition of this iOS 9 App Development Essentials book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters Next modify the cellForRowAtIndexPath method to return the item to be displayed using the row number argument as an index into the siteNames array override func tableView tableView UITableView cellForRowAtIndexPath indexPath NSIndexPath UITableViewCell let cell tableView dequeueReusableCellWithIdentifier Cell forIndexPath indexPath cell textLabel text siteNames indexPath row return cell Click on the run button located in the Xcode toolbar to test the current state of the application using a physical iPad or iPhone Plus device or a corresponding simulator as the target Once the application loads rotate the device into landscape mode using the Hardware Rotate Left menu if running on a simulator Figure 33 2 At this point the detail

    Original URL path: http://www.techotopia.com/index.php/An_iOS_9_Split_View_Master-Detail_Example (2016-02-13)
    Open archived version from archive

  • A Guide to Multitasking in iOS 9 - Techotopia
    example would use the compact width and regular height size class whilst the same app running in portrait orientation would use regular width and compact height size class When running in a multitasking environment the primary and secondary apps will pass through a range of compact and regular widths depending on the prevailing multitasking configuration The diagrams in Figure 34 4 illustrate the way in which the different multitasking modes translate to equivalent regular and compact size classes Figure 34 4 The above rules change slightly when the app is running in Split View mode on an iPad Pro Due to the larger screen size of the iPad Pro both apps are presented in Split View mode using the regular width as illustrated in Figure 34 5 Figure 34 5 Implementing multitasking support within an iOS app is essentially a matter of designing layouts that adapt appropriately to the different size classes outlined in the above diagram Multitasking and the Master Detail Split View The previous chapter introduced the master detail split view interface In this configuration both a master panel and a detail panel are displayed at the same time whereby selecting an item from the master panel influences what is displayed in the detail panel While this split view approach should not be confused with the multitasking Split View mode it is useful to know that a master detail user interface will automatically work within multitasking Consider for the purpose of an example the SplitView app created in the previous chapter When selected as a secondary app the master panel will appear within the Slide Over panel as shown in Figure 34 6 eBookFrenzy com Purchase the full edition of this iOS 9 App Development Essentials book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters Figure 34 6 When an item is selected from the master panel the detail panel is then displayed in place of the master panel together with a toolbar button to return to the master panel This same behavior applies in Split View mode as shown in Figure 34 7 where the detail panel is displayed in Split View mode alongside the Photos app Figure 34 7 Handling Multitasking in Code Much can be achieved in terms of using Auto Layout and Size Classes to adapt to the size changes associated with multitasking There will however inevitably be instances where some code needs to be executed when a scene transitions from one size class to another for example when an app transitions from Slide Over to Split View Fortunately UIKit will call three delegate methods on the container instance typically a view controller of the current scene during the transition to notify it of the transition where code can be added to perform app specific tasks at different points in the transition These delegate methods are outlined below in the order in which they are called during the

    Original URL path: http://www.techotopia.com/index.php/A_Guide_to_Multitasking_in_iOS_9 (2016-02-13)
    Open archived version from archive

  • An iOS 9 Multitasking Example - Techotopia
    the Main storyboard file and dragging and dropping a Horizontal Stack View from the Object Library panel onto the scene canvas With the Stack View selected display the Auto Layout Pin menu and set Spacing to nearest neighbor constraints on all four sides of the view with the spacing set to 0 and the Constrain to margins option enabled Before clicking on the Add 4 Constraints button set the Update Frames menu to All Frames in Container as illustrated in Figure 35 2 Figure 35 2 Display the Document Outline panel and select the Stack View entry Using the Attributes Inspector panel set the Alignment to Center and the Distribution property to Fill Equally Drag an Image object and drop it onto the stack view instance in the storyboard scene canvas Locate the Text View object within the Object Library panel and drag it to the right hand edge of the Image view within the scene canvas When a bold blue vertical line appears referenced by the arrow in Figure 35 3 indicating that the Text View will be placed to the right of the Image view in the stack drop the Text View to add it to the scene Figure 35 3 eBookFrenzy com Purchase the full edition of this iOS 9 App Development Essentials book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters With the Image view selected use the Attributes Inspector panel to set the Mode attribute to Aspect Fit and the Image menu to Waterfalls Select the Text View object and stretch it vertically so that all of the Latin text is visible With the Text View object still selected display the Auto Layout Pin menu and enable the Height constraint option based on the current value before clicking on the Add 1 Constraint button At this point the user interface layout should match Figure 35 4 Figure 35 4 Designing the Compact Width Size Class When the app is displayed in Slide Over and certain Split View configurations the compact size class will be used to arrange the scene layout To ensure that the scene appears correctly in these situations this size class now needs to be designed within the project With the Main storyboard file still loaded into Interface Builder use the size class menu along the bottom edge of the storyboard Figure 35 5 to change the class to Compact Width Regular Height Figure 35 5 With Interface Builder now displaying the compact width regular height size class the stack view needs to be configured to use vertical orientation to accommodate the narrower width available for the subviews Select the Stack View object within the Document Outline panel and display the Attributes Inspector panel When the app is displayed in compact width the axis orientation of the stack view object needs to change from horizontal to vertical To configure this click on the button located to the

    Original URL path: http://www.techotopia.com/index.php/An_iOS_9_Multitasking_Example (2016-02-13)
    Open archived version from archive

  • Implementing a Page based iOS 9 Application with UIPageViewController - Techotopia
    a data source which in turn is responsible for providing view controller objects as required for each page The data source takes the form of a class instance that implements the UIPageViewControllerDataSource protocol which at a minimum must implement the following two methods viewControllerAfterViewController This method is passed a view controller representing the currently displayed page and is required to return the view controller corresponding to the next page in the paging sequence viewControllerBeforeViewController This method is passed the view controller representing the currently displayed page and is required to return the view controller corresponding to the previous page in the paging sequence The mechanism used to create the requested view controllers and the content therein will generally be application specific and is at the discretion of the developer Apple does however recommend that in order to ensure optimal performance and minimal resource usage the view controllers be created on an as needed basis rather than pre created When a UIPageViewController object is initialized a number of configuration options may be specified to configure the appearance and behavior of the contained views eBookFrenzy com Purchase the full edition of this iOS 9 App Development Essentials book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters Navigation Orientation The page controller is capable of transitioning between views using either a vertical or horizontal paradigm In the case of horizontal navigation page transitions take place in the same way pages are turned in a physical book by sweeping a finger on the screen either left or right In the case of horizontal navigation pages are turned by making vertical gestures in much the same way the pages of a wall calendar are flipped These options are configured using the following constants UIPageViewControllerNavigationOrientation Horizontal UIPageViewControllerNavigationOrientation Vertical Spine Location The UIPageViewController class allows for the location of the spine to be configured The term spine in this context is analogous to the spine of a book and dictates the location of the axis on which each page will turn The behavior of the spine location settings vary depending on the navigation orientation setting For example the default for most configurations is UIPageViewControllerSpineLocation Min which places the spine on the left hand side or top of the screen depending on whether the navigation orientation is horizontal or vertical Similarly the UIPageViewControllerSpineLocation Max setting will position the spine at the right or bottom edge of the display In order to display two pages simultaneously the UIPageViewControllerSpineLocationMid setting should be used The view controller may also be configured to treat pages as being double sided via the doubleSided property Note that when using UIPageViewControllerSpineLocationMid spine location it will be necessary to provide the page controller with two view controllers one for the left hand page and one for the right for each page turn Similarly when using either the min or max spine location together with the double sided setting view controllers

    Original URL path: http://www.techotopia.com/index.php/Implementing_a_Page_based_iOS_9_Application_with_UIPageViewController (2016-02-13)
    Open archived version from archive



  •