SlideShare una empresa de Scribd logo
1 de 16
Descargar para leer sin conexión
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

Más contenido relacionado

Destacado

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
 

Destacado (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
 

Similar a 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
 

Similar a 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)
 

Más 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
 

Más 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
 

Último

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
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
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
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Último (20)

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
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
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
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
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!
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

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