SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
UIVIEW
                          употреба, хитрости и задължения




Thursday, January 5, 12
UIVIEW


    • defines              a rectangular region on the screen

    • drawing             and touch events

    • placement              and sizing of other views




Thursday, January 5, 12
CONTAINER VIEW

    • resizing              behavior                        Групиране
    • hiding              a view

    • alpha               (transparency)

    • mathematical                 transform to the coordinate system

    • responder               chain (touches)


Thursday, January 5, 12
UIVIEW AND CALAYER
                          CHAPTER 1
                          View and Window Architecture




                          Figure 1-1      Architecture of the views in a sample application


                                         UIView    UIWindow
                           UIImageView




                          UIToolbar    UIBarButtonItem
                                        (internal view)

                                 UIKit views                      Core Animation layers



                          The use of Core Animation layer objects has important implications for performance. The actual drawing
                          code of a view object is called as little as possible, and when the code is called, the results are cached by
                          Core Animation and reused as much as possible later. Reusing already-‐rendered content eliminates the

                          Всяко View е изгранено от CALayer
                          expensive drawing cycle usually needed to update views. Reuse of this content is especially important during
                          animations, where the existing content can be manipulated. Such reuse is much less expensive than creating
                          new content.


Thursday, January 5, 12
CALAYER
                              Quartz 2D

                                          Reuse
                              Drawing
                 Hardware
                  buffers
                            Performance    Render
                Animation
                              Transform
                               matrices



Thursday, January 5, 12
CHAPTER 1



                              CUSTOM DRAWING
                     View and Window Architecture




                     Figure 1-7      UIKit interactions with your view objects

                                                      iPhone OS
                                                                                              Your Application
                                                   Touch Framework
                                                                                           touches
                                                                                            setNeedsLayout
                                                                                                                         Mark redraw
                                                                            Touches
                                                         UIKit                              setNeedsDisplay
                                                                                            frame, alpha, etc.

                                                                                           layoutSubviews

                                                                           • Buffers        setNeedsDisplay
                                                                           • Images         frame, alpha, etc.
                                                                           • Attributes
                                                                           • Geometry      drawRect
                                                                           • Animations
                                                      Compositor                            Draw images, text, etc.


                                                   Graphics hardware




                     The following steps break the event sequence in Figure 1-‐7 (page 23) down even further and explain what
                     happens at each stage and how you might want your application to react in response.

                     1.   The user touches the screen.

                     2.                  APPLE: Avoid custom drawing!
                          The hardware reports the touch event to the UIKit framework.

                     3.   The UIKit framework packages the touch into a UIEvent object and dispatches it to the appropriate
                          view. (For a detailed explanation of how UIKit delivers events to your views, see Event Handling Guide
                          for iOS.)
Thursday, January 5, 12
CHAPTER 1
                                                                                             View and Window Architecture



      CHAPTER 1
      Overview of Quartz 2D
                                                                  UIKIT                      Figure 1-‐4 shows this coordinate system r
                                                                                             windows and views define their own loca
                                                                                             to the view or window origin instead of r

                                                                                             Figure 1-4      Coordinate system orient
      Figure 1-5
                  Quartz 2D                                           UIKit
                          Modifying the coordinate system creates a mirrored image.

              y                                       (0,0)
                                                                                         x
                                                                                             (0,0)
                                                                                                                                x




      (0,0)
                                                              y
                                              x
                     Default Coordinates                          Modified Coordinates



  • drawing                  - own coordinate system
                                                                                                     y
  • geometry     changes - superview’s
       coordinate system.
                        flipped_coordinates.eps
                                                  Cocoa Drawing
                                                  Apple Computer, Inc.
                                                  February 9, 2006                           Because every view and window defines
Thursday, January 5, 12                                                                      coordinate system is in effect at any given
UIVIEW АМИНАЦИИ

    • frame,              bounds, center

    • transform             — rotate or scale the view.

    • alpha

    • backgroundColor

    • contentStretch

    • //autoresizingMask
Thursday, January 5, 12
FRAME & BOUNDS
                                       Frame rectangle                  Bounds rectangle


                          (40,40)                              (0,0)




                      Center
                    (160,230)                            380                               380




                                                                              240
                                            240


                                    coordinates in                     coordinates
                                      superview                           in self
Thursday, January 5, 12
РАЗТЯГАНЕ НА КОНТЕНТ
          CHAPTER 1
          View and Window Architecture




          Stretchable Views
          You can designate a portion of a view as stretchable so that when the size of the view changes only the
          content in the stretchable portion is affected. You typically use stretchable areas for buttons or other views
          where part of the view defines a repeatable pattern. The stretchable area you specify can allow for stretching
                                                                                                                                          Core Animation layer
          along one or both axes of the view. Of course, when stretching a view along two axes, the edges of the view
          must also define a repeatable pattern to avoid any distortion. Figure 1-‐3 shows how this distortion manifests

               stretchable area - contentStretch property
          itself in a view. The color from each of the view’s original pixels is replicated to fill the corresponding area in
          the larger view.

          Figure 1-3      Stretching the background of a button

                (0,0)




                                                         (1,1)

                                                                                                                                UIViewContentModeScaleToFill
                                                                                                                                UIViewContentModeScaleAspectFit
                                                                                                                                UIViewContentModeScaleAspectFill



          You specify the stretchable area of a view using the contentStretch property. This property accepts a
          rectangle whose values are normalized to the range 0.0 to 1.0. When stretching the view, the system
          multiplies these normalized values by the view’s current bounds and scale factor to determine which pixel
          or pixels need to be stretched. The use of normalized values alleviates the need for you to update the
          contentStretch property every time the bounds of your view change.

      The view’s content mode also plays a role in determining how the view’s stretchable area is used. Stretchable
      areas are only used when the content mode would cause the view’s content to be scaled. This means that
      stretchable views are supported only with the UIViewContentModeScaleToFill,
      UIViewContentModeScaleAspectFit, and UIViewContentModeScaleAspectFill content modes. If
Thursday, January 5, 12
ПРИМЕРИ




Thursday, January 5, 12
РЕЦИКЛИРАНЕ НА КОНТЕНТ


                     Първоначално
                                    Bitmap
                     изобразяване
                  Render content




Thursday, January 5, 12
TOUCHES

            User input     Touch Framework       UIKit

                                                         UIEvent

            UIView            UIView
                                             UIView
          (superview)       (superview)
                          Responder chain




Thursday, January 5, 12
PERFORMANCE

    • ViewControllers            - колко и за какво се използват

    • Избягвайте             да чертаете сами

    • Използвайте              contentModes & AutoResizingMask

    • aView.opaque             = YES; когато е възможно

    • Scrolling           optimisation


Thursday, January 5, 12
CUSTOM VIEWS


    •   initWithFrame:                 Не забравяй!
    •   dealloc

    •   autoresizingMask

    •   addGestureRecognizer: or touchesBegan:withEvent:




Thursday, January 5, 12
APPENDIX A
                          The iOS Environment



                   APPLICATION SANDBOX
                          Figure A-1      Sandbox directories in iOS

                                                                         App Sandbox


                                                                                      MyApp.app

                                                                                      Documents
                                                                App
                                                                                     Library
                                               ...
                                                                                     tmp

                                                      ...
                                                                         App Sandbox


                                                                App            ...
                                                                         App Sandbox


                                                                App            ...

                          Important: The purpose of a sandbox is to limit the damage that a compromised app can cause to the
                          system. Sandboxes do not prevent attacks from happening to a particular app and it is still your responsibility
                          to code defensively to prevent attacks. For example, if your app does not validate user input and there is an
                          exploitable buffer overflow in your input-‐handling code, an attacker could still hijack your app or cause it to
                          crash. The sandbox only prevents the hijacked app from affecting other apps and other parts of the system.
Thursday, January 5, 12

Contenu connexe

En vedette

iOS App 開發 -- Storybard 基礎練習、APP 上架、IAP
iOS App 開發 -- Storybard 基礎練習、APP 上架、IAPiOS App 開發 -- Storybard 基礎練習、APP 上架、IAP
iOS App 開發 -- Storybard 基礎練習、APP 上架、IAPMing-Sian Lin
 
Fast-paced Introduction to Android Internals
Fast-paced Introduction to Android InternalsFast-paced Introduction to Android Internals
Fast-paced Introduction to Android InternalsHamilton Turner
 
File system in iOS
File system in iOSFile system in iOS
File system in iOSPurvik Rana
 
Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1Subhransu Behera
 
Android Forensics: Exploring Android Internals and Android Apps
Android Forensics: Exploring Android Internals and Android AppsAndroid Forensics: Exploring Android Internals and Android Apps
Android Forensics: Exploring Android Internals and Android AppsMoe Tanabian
 
Q4.11: Introduction to eMMC
Q4.11: Introduction to eMMCQ4.11: Introduction to eMMC
Q4.11: Introduction to eMMCLinaro
 
iOS Release Management
iOS Release ManagementiOS Release Management
iOS Release ManagementSamuel Chow
 
Configuration As Code - Adoption of the Job DSL Plugin at Netflix
Configuration As Code - Adoption of the Job DSL Plugin at NetflixConfiguration As Code - Adoption of the Job DSL Plugin at Netflix
Configuration As Code - Adoption of the Job DSL Plugin at NetflixJustin Ryan
 

En vedette (10)

iOS App 開發 -- Storybard 基礎練習、APP 上架、IAP
iOS App 開發 -- Storybard 基礎練習、APP 上架、IAPiOS App 開發 -- Storybard 基礎練習、APP 上架、IAP
iOS App 開發 -- Storybard 基礎練習、APP 上架、IAP
 
Fast-paced Introduction to Android Internals
Fast-paced Introduction to Android InternalsFast-paced Introduction to Android Internals
Fast-paced Introduction to Android Internals
 
File system in iOS
File system in iOSFile system in iOS
File system in iOS
 
Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1
 
eMMC 5.0 Total IP Solution
eMMC 5.0 Total IP SolutioneMMC 5.0 Total IP Solution
eMMC 5.0 Total IP Solution
 
Android Forensics: Exploring Android Internals and Android Apps
Android Forensics: Exploring Android Internals and Android AppsAndroid Forensics: Exploring Android Internals and Android Apps
Android Forensics: Exploring Android Internals and Android Apps
 
Q4.11: Introduction to eMMC
Q4.11: Introduction to eMMCQ4.11: Introduction to eMMC
Q4.11: Introduction to eMMC
 
File systems for Embedded Linux
File systems for Embedded LinuxFile systems for Embedded Linux
File systems for Embedded Linux
 
iOS Release Management
iOS Release ManagementiOS Release Management
iOS Release Management
 
Configuration As Code - Adoption of the Job DSL Plugin at Netflix
Configuration As Code - Adoption of the Job DSL Plugin at NetflixConfiguration As Code - Adoption of the Job DSL Plugin at Netflix
Configuration As Code - Adoption of the Job DSL Plugin at Netflix
 

Similaire à iOS Views

Kernel Architecture
Kernel ArchitectureKernel Architecture
Kernel ArchitectureThakursahib
 
01.egovFrame Training Book II
01.egovFrame Training Book II01.egovFrame Training Book II
01.egovFrame Training Book IIChuong Nguyen
 
Desenvolvimento com iOS no LinguÁgil 2012
Desenvolvimento com iOS no LinguÁgil 2012Desenvolvimento com iOS no LinguÁgil 2012
Desenvolvimento com iOS no LinguÁgil 2012Cleverson Sacramento
 
Gef tutorial 2005
Gef tutorial 2005Gef tutorial 2005
Gef tutorial 2005Ryan Wang
 
Junos Space SDK - Imagination, Ideas, Innovation
Junos Space SDK - Imagination, Ideas, InnovationJunos Space SDK - Imagination, Ideas, Innovation
Junos Space SDK - Imagination, Ideas, InnovationJuniper Networks
 
Build Your Own Multi-Touch Interface with Java and JavaFX Technology
Build Your Own Multi-Touch Interface with Java and JavaFX TechnologyBuild Your Own Multi-Touch Interface with Java and JavaFX Technology
Build Your Own Multi-Touch Interface with Java and JavaFX Technologyelliando dias
 
2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorialtutorialsruby
 
2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorialtutorialsruby
 
Radu’S Robots
Radu’S RobotsRadu’S Robots
Radu’S Robotsraxorio
 
Magnolia CMS 5.0 - Architecture
Magnolia CMS 5.0 - ArchitectureMagnolia CMS 5.0 - Architecture
Magnolia CMS 5.0 - ArchitecturePhilipp Bärfuss
 
2008 brokerage 04 smart vision system [compatibility mode]
2008 brokerage 04 smart vision system [compatibility mode]2008 brokerage 04 smart vision system [compatibility mode]
2008 brokerage 04 smart vision system [compatibility mode]imec.archive
 
2008 brokerage 04 smart vision system [compatibility mode]
2008 brokerage 04 smart vision system [compatibility mode]2008 brokerage 04 smart vision system [compatibility mode]
2008 brokerage 04 smart vision system [compatibility mode]imec.archive
 
PHX Session #5 : Architecture Without Big Design Up Front (Garibay)
PHX Session #5 : Architecture Without Big Design Up Front (Garibay)PHX Session #5 : Architecture Without Big Design Up Front (Garibay)
PHX Session #5 : Architecture Without Big Design Up Front (Garibay)Steve Lange
 

Similaire à iOS Views (20)

Kernel Architecture
Kernel ArchitectureKernel Architecture
Kernel Architecture
 
01.egovFrame Training Book II
01.egovFrame Training Book II01.egovFrame Training Book II
01.egovFrame Training Book II
 
Desenvolvimento com iOS no LinguÁgil 2012
Desenvolvimento com iOS no LinguÁgil 2012Desenvolvimento com iOS no LinguÁgil 2012
Desenvolvimento com iOS no LinguÁgil 2012
 
Gef tutorial 2005
Gef tutorial 2005Gef tutorial 2005
Gef tutorial 2005
 
426 lecture2: AR Technology
426 lecture2: AR Technology426 lecture2: AR Technology
426 lecture2: AR Technology
 
Junos Space SDK - Imagination, Ideas, Innovation
Junos Space SDK - Imagination, Ideas, InnovationJunos Space SDK - Imagination, Ideas, Innovation
Junos Space SDK - Imagination, Ideas, Innovation
 
Vb
VbVb
Vb
 
Build Your Own Multi-Touch Interface with Java and JavaFX Technology
Build Your Own Multi-Touch Interface with Java and JavaFX TechnologyBuild Your Own Multi-Touch Interface with Java and JavaFX Technology
Build Your Own Multi-Touch Interface with Java and JavaFX Technology
 
2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial
 
2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial
 
Unity 3d scripting tutorial
Unity 3d scripting tutorialUnity 3d scripting tutorial
Unity 3d scripting tutorial
 
Radu’S Robots
Radu’S RobotsRadu’S Robots
Radu’S Robots
 
Uml3
Uml3Uml3
Uml3
 
05 ai uml_illik_students_part_2_eng
05 ai uml_illik_students_part_2_eng05 ai uml_illik_students_part_2_eng
05 ai uml_illik_students_part_2_eng
 
Unit 5
Unit 5Unit 5
Unit 5
 
Unit 5
Unit 5Unit 5
Unit 5
 
Magnolia CMS 5.0 - Architecture
Magnolia CMS 5.0 - ArchitectureMagnolia CMS 5.0 - Architecture
Magnolia CMS 5.0 - Architecture
 
2008 brokerage 04 smart vision system [compatibility mode]
2008 brokerage 04 smart vision system [compatibility mode]2008 brokerage 04 smart vision system [compatibility mode]
2008 brokerage 04 smart vision system [compatibility mode]
 
2008 brokerage 04 smart vision system [compatibility mode]
2008 brokerage 04 smart vision system [compatibility mode]2008 brokerage 04 smart vision system [compatibility mode]
2008 brokerage 04 smart vision system [compatibility mode]
 
PHX Session #5 : Architecture Without Big Design Up Front (Garibay)
PHX Session #5 : Architecture Without Big Design Up Front (Garibay)PHX Session #5 : Architecture Without Big Design Up Front (Garibay)
PHX Session #5 : Architecture Without Big Design Up Front (Garibay)
 

Plus de Marian Ignev

Какво е Startup?
Какво е Startup?Какво е Startup?
Какво е Startup?Marian Ignev
 
PaaS бъдещето на креативния програмист!
PaaS бъдещето на креативния програмист!PaaS бъдещето на креативния програмист!
PaaS бъдещето на креативния програмист!Marian Ignev
 
iOS Tips + ModalVC
iOS Tips + ModalVCiOS Tips + ModalVC
iOS Tips + ModalVCMarian Ignev
 
iOS UI Table Views
iOS UI Table ViewsiOS UI Table Views
iOS UI Table ViewsMarian Ignev
 
iOS Memory management & Navigation
iOS Memory management & NavigationiOS Memory management & Navigation
iOS Memory management & NavigationMarian Ignev
 
iOS Architecture and MVC
iOS Architecture and MVCiOS Architecture and MVC
iOS Architecture and MVCMarian Ignev
 
iOS Development - Intro
iOS Development - IntroiOS Development - Intro
iOS Development - IntroMarian Ignev
 

Plus de Marian Ignev (8)

Какво е Startup?
Какво е Startup?Какво е Startup?
Какво е Startup?
 
PaaS бъдещето на креативния програмист!
PaaS бъдещето на креативния програмист!PaaS бъдещето на креативния програмист!
PaaS бъдещето на креативния програмист!
 
iOS Tips + ModalVC
iOS Tips + ModalVCiOS Tips + ModalVC
iOS Tips + ModalVC
 
iOS UI Table Views
iOS UI Table ViewsiOS UI Table Views
iOS UI Table Views
 
iOS Memory management & Navigation
iOS Memory management & NavigationiOS Memory management & Navigation
iOS Memory management & Navigation
 
The messy lecture
The messy lectureThe messy lecture
The messy lecture
 
iOS Architecture and MVC
iOS Architecture and MVCiOS Architecture and MVC
iOS Architecture and MVC
 
iOS Development - Intro
iOS Development - IntroiOS Development - Intro
iOS Development - Intro
 

Dernier

Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 

Dernier (20)

Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 

iOS Views

  • 1. UIVIEW употреба, хитрости и задължения Thursday, January 5, 12
  • 2. UIVIEW • defines a rectangular region on the screen • drawing and touch events • placement and sizing of other views Thursday, January 5, 12
  • 3. CONTAINER VIEW • resizing behavior Групиране • hiding a view • alpha (transparency) • mathematical transform to the coordinate system • responder chain (touches) Thursday, January 5, 12
  • 4. UIVIEW AND CALAYER CHAPTER 1 View and Window Architecture Figure 1-1 Architecture of the views in a sample application UIView UIWindow UIImageView UIToolbar UIBarButtonItem (internal view) UIKit views Core Animation layers The use of Core Animation layer objects has important implications for performance. The actual drawing code of a view object is called as little as possible, and when the code is called, the results are cached by Core Animation and reused as much as possible later. Reusing already-‐rendered content eliminates the Всяко View е изгранено от CALayer expensive drawing cycle usually needed to update views. Reuse of this content is especially important during animations, where the existing content can be manipulated. Such reuse is much less expensive than creating new content. Thursday, January 5, 12
  • 5. CALAYER Quartz 2D Reuse Drawing Hardware buffers Performance Render Animation Transform matrices Thursday, January 5, 12
  • 6. CHAPTER 1 CUSTOM DRAWING View and Window Architecture Figure 1-7 UIKit interactions with your view objects iPhone OS Your Application Touch Framework touches setNeedsLayout Mark redraw Touches UIKit setNeedsDisplay frame, alpha, etc. layoutSubviews • Buffers setNeedsDisplay • Images frame, alpha, etc. • Attributes • Geometry drawRect • Animations Compositor Draw images, text, etc. Graphics hardware The following steps break the event sequence in Figure 1-‐7 (page 23) down even further and explain what happens at each stage and how you might want your application to react in response. 1. The user touches the screen. 2. APPLE: Avoid custom drawing! The hardware reports the touch event to the UIKit framework. 3. The UIKit framework packages the touch into a UIEvent object and dispatches it to the appropriate view. (For a detailed explanation of how UIKit delivers events to your views, see Event Handling Guide for iOS.) Thursday, January 5, 12
  • 7. CHAPTER 1 View and Window Architecture CHAPTER 1 Overview of Quartz 2D UIKIT Figure 1-‐4 shows this coordinate system r windows and views define their own loca to the view or window origin instead of r Figure 1-4 Coordinate system orient Figure 1-5 Quartz 2D UIKit Modifying the coordinate system creates a mirrored image. y (0,0) x (0,0) x (0,0) y x Default Coordinates Modified Coordinates • drawing - own coordinate system y • geometry changes - superview’s coordinate system. flipped_coordinates.eps Cocoa Drawing Apple Computer, Inc. February 9, 2006 Because every view and window defines Thursday, January 5, 12 coordinate system is in effect at any given
  • 8. UIVIEW АМИНАЦИИ • frame, bounds, center • transform — rotate or scale the view. • alpha • backgroundColor • contentStretch • //autoresizingMask Thursday, January 5, 12
  • 9. FRAME & BOUNDS Frame rectangle Bounds rectangle (40,40) (0,0) Center (160,230) 380 380 240 240 coordinates in coordinates superview in self Thursday, January 5, 12
  • 10. РАЗТЯГАНЕ НА КОНТЕНТ CHAPTER 1 View and Window Architecture Stretchable Views You can designate a portion of a view as stretchable so that when the size of the view changes only the content in the stretchable portion is affected. You typically use stretchable areas for buttons or other views where part of the view defines a repeatable pattern. The stretchable area you specify can allow for stretching Core Animation layer along one or both axes of the view. Of course, when stretching a view along two axes, the edges of the view must also define a repeatable pattern to avoid any distortion. Figure 1-‐3 shows how this distortion manifests stretchable area - contentStretch property itself in a view. The color from each of the view’s original pixels is replicated to fill the corresponding area in the larger view. Figure 1-3 Stretching the background of a button (0,0) (1,1) UIViewContentModeScaleToFill UIViewContentModeScaleAspectFit UIViewContentModeScaleAspectFill You specify the stretchable area of a view using the contentStretch property. This property accepts a rectangle whose values are normalized to the range 0.0 to 1.0. When stretching the view, the system multiplies these normalized values by the view’s current bounds and scale factor to determine which pixel or pixels need to be stretched. The use of normalized values alleviates the need for you to update the contentStretch property every time the bounds of your view change. The view’s content mode also plays a role in determining how the view’s stretchable area is used. Stretchable areas are only used when the content mode would cause the view’s content to be scaled. This means that stretchable views are supported only with the UIViewContentModeScaleToFill, UIViewContentModeScaleAspectFit, and UIViewContentModeScaleAspectFill content modes. If Thursday, January 5, 12
  • 12. РЕЦИКЛИРАНЕ НА КОНТЕНТ Първоначално Bitmap изобразяване Render content Thursday, January 5, 12
  • 13. TOUCHES User input Touch Framework UIKit UIEvent UIView UIView UIView (superview) (superview) Responder chain Thursday, January 5, 12
  • 14. PERFORMANCE • ViewControllers - колко и за какво се използват • Избягвайте да чертаете сами • Използвайте contentModes & AutoResizingMask • aView.opaque = YES; когато е възможно • Scrolling optimisation Thursday, January 5, 12
  • 15. CUSTOM VIEWS • initWithFrame: Не забравяй! • dealloc • autoresizingMask • addGestureRecognizer: or touchesBegan:withEvent: Thursday, January 5, 12
  • 16. APPENDIX A The iOS Environment APPLICATION SANDBOX Figure A-1 Sandbox directories in iOS App Sandbox MyApp.app Documents App Library ... tmp ... App Sandbox App ... App Sandbox App ... Important: The purpose of a sandbox is to limit the damage that a compromised app can cause to the system. Sandboxes do not prevent attacks from happening to a particular app and it is still your responsibility to code defensively to prevent attacks. For example, if your app does not validate user input and there is an exploitable buffer overflow in your input-‐handling code, an attacker could still hijack your app or cause it to crash. The sandbox only prevents the hijacked app from affecting other apps and other parts of the system. Thursday, January 5, 12