SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 
Unity 3d scripting tutorial
Unity 3d scripting tutorialUnity 3d scripting tutorial
Unity 3d scripting tutorial
 
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
 
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)
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Kürzlich hochgeladen (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

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