ios app components
play

iOS App Components CS 4720 Mobile Application Development CS 4720 - PowerPoint PPT Presentation

iOS App Components CS 4720 Mobile Application Development CS 4720 iOS Architecture CS 4720 2 Building Blocks UIApplication The main entry point for your app Each app has exactly one instance of this class Provides the


  1. iOS App Components CS 4720 – Mobile Application Development CS 4720

  2. iOS Architecture CS 4720 2

  3. Building Blocks • UIApplication – The main entry point for your app – Each app has exactly one instance of this class – Provides the main interface back to the OS – Handles all incoming info from the OS (such as touch event, memory warnings, incoming phone call, etc.) – Passes these messages off to… CS 4720 3

  4. Building Blocks • UIApplicationDelegate – Manages the running of your app – Handles “major” events, like app swtiching, app initialization, etc. CS 4720 4

  5. AppDelegate.swift import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? CS 4720 5

  6. AppDelegate.swift func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { return true } CS 4720 6

  7. Other Components • UIDocument: allows for internal app documents and data stores • ViewController : manages all views (scenes) for the app • UIWindow : the one window of the iOS device (only have more if external display) • View Objects: all the widgets in a scene CS 4720 7

  8. The Main App Loop CS 4720 8

  9. The Main App Loop • The OS receives input and passes it to the UIApplication • Which passes it to the UIApplicationDelegate • Which passes it to the UIWindow • Which passes it to the currently seen ViewController CS 4720 9

  10. The Main App Loop • Other events are passed to the “First Responder” object that is available • Everything that can accept and respond to an event is a responder object • The first responder object is the top-level designated object in a view to handle events CS 4720 10

  11. App States CS 4720 11

  12. AppStates • applicationWillEnterForeground – starting to move to active state • applicationDidBecomeActive – called right before view displayed • applicationWillResignActive – first call before going into background • applicationDidEnterBackground – now is in background • applicatinoWillTerminate – will end CS 4720 12

  13. On Launch • application comes in with didFinishLaunchingWithOptions • Check dictionary launchOptions for info on why was launched (somewhat like looking at the Intent ) • Any app not responding in 5 seconds is killed • Start initialization • UIKit grabs first storyboard and ViewController CS 4720 13

  14. Inside the View CS 4720 14

  15. Using Segues • Instead of Intents like Android, we’ll use Segues to pass data between Scenes / ViewControllers CS 4720 15

  16. MVC in iOS • We again see Model-View-Controller as part of the foundation for a mobile system • Because of the nature of Objective-C and NeXTSTEP, MVC is one of the primary design patterns for both iOS and OS X CS 4720 16

  17. MVC in iOS CS 4720 17

  18. MVC in iOS CS 4720 18

  19. MVC in iOS • Model: The base classes you write to hold data – Could subclass NSObject/Object – Could connect to a database or other data source – Could be a simple class you write CS 4720 19

  20. MVC in iOS • View: Any rectangular drawable object on the screen – Various Stack, Table, and Collection Views – Image, Text, Picker Views – Map and WebKit View – Scene Kit View (for 3D scenes) – Manages drawing its area on the screen – Can contain other views (or be contained) – Responds to touch and other events CS 4720 20

  21. MVC in iOS • Controller: The ViewController class – Each ViewController manages a hierarchy of Views – The view property of the class contains the root – Views are access lazily; that is, they are only loaded when needed – Updates the contents of the views, usually in response to changes to the underlying data – Responds to user interactions with views – Resizes views and manages the layout of the overall interface CS 4720 21

  22. Building up in MVC • Start by considering your data – Where does it come from? – How will you store it? – What sort of access do you need from it? CS 4720 22

  23. Building up in MVC • Storyboard your idea – Just as with Android, layout each screen – What views make up each screen? • Text? • A Table? • An Image? – What happens when you touch or swipe on each view? Or on the screen? CS 4720 23

  24. Building up in MVC • Create the appropriate Controller type • Add Views to the Controller to get the layout the way you want it • Start with dummy data • Run in the simulator often! • Check and adjust your constraints to get everything on screen • Test rotation! CS 4720 24

  25. Building up in MVC • In your Storyboard, link the various Views back to the code using ctrl-click/drag • Do the same for buttons and other controls • Load data as needed to refresh the view (often happens automatically) • Add in code to handle user events, like touches and swipes • Add Navigation Controllers to allow for switching between scenes CS 4720 25

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend