SlideShare uma empresa Scribd logo
1 de 13
Baixar para ler offline
•
Unit 2—Lesson 9:
•
Controls in Action
Controls
• Buttons

• Switches 

• Sliders

• Text fields
Buttons (UIButton)
@IBAction func buttonTapped(_ sender: Any)
// Code to respond to button
}
Buttons (UIButton)
Switches (UISwitch)
@IBAction func switchToggled(_ sender: UISwitch) {
if sender.isOn {
print("The switch is on!")
} else {
print("The switch is off.")
}
}
Sliders (UISlider)
@IBAction func sliderValueChanged(_ sender: UISlider) {
print(sender.value)
}
Configuration
Sliders (UISlider)
Property Description
Minimum Value Lowest number value the slider may represent
Maximum Value Highest number value the slider may represent
Current Starting number value the slider will represent
Min Image Optional image on the minimum end of the slider
Max Image Optional image on the maximum end of the slider
Text fields (UITextField)
@IBAction func keyboardReturnKeyTapped(_ sender: UITextField) {
if let text = sender.text {
print(text)
}
}
Text fields (UITextField)
Property Description
Placeholder Text Text displayed when the text field is empty
Text Text displayed by the text field
Capitalization How the keyboard deals with capitalization
Correction Enables or disables autocorrect
Keyboard
Which keyboard is displayed—for example, email,
web, or default
Return Key Text on the return key
Secure
Specific text fields that don't display their
contents, commonly used for passwords
Actions and outlets
•
@IBOutlet weak var toggle: UISwitch!
•
@IBOutlet weak var slider: UISlider!
•
@IBAction func buttonTapped(_ sender: UIButton) {
•
if toggle.isOn {
•
. . .
•
}
•
print(slider.value)
•
}
Controls in Action
Unit 2—Lesson 9
Use Interface Builder to add buttons, switches, and sliders to a scene

Create actions and outlets, write some basic code, and gain an understanding of
how these tools work together
Lab: Basic Interactions
Unit 2—Lesson 9
Create and compile an app with two buttons that, when tapped, change the
contents of a label
© 2017 Apple Inc. 

This work is licensed by Apple Inc. under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license.

Mais conteúdo relacionado

Mais procurados

Creative Web 2 - JavaScript
Creative Web 2 - JavaScript Creative Web 2 - JavaScript
Creative Web 2 - JavaScript
Lukas Oppermann
 
12 High Level UI Event Handling
12 High Level UI Event Handling12 High Level UI Event Handling
12 High Level UI Event Handling
corneliuskoo
 
Laboratory activity 3 b2
Laboratory activity 3 b2Laboratory activity 3 b2
Laboratory activity 3 b2
Jomel Penalba
 

Mais procurados (20)

Event handling in Java(part 2)
Event handling in Java(part 2)Event handling in Java(part 2)
Event handling in Java(part 2)
 
Event handling in Java(part 1)
Event handling in Java(part 1)Event handling in Java(part 1)
Event handling in Java(part 1)
 
Redux pattens - JSHeroes 2018
Redux pattens - JSHeroes 2018Redux pattens - JSHeroes 2018
Redux pattens - JSHeroes 2018
 
Deep Dive into React Hooks
Deep Dive into React HooksDeep Dive into React Hooks
Deep Dive into React Hooks
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 
Creative Web 2 - JavaScript
Creative Web 2 - JavaScript Creative Web 2 - JavaScript
Creative Web 2 - JavaScript
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITYDOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
12 High Level UI Event Handling
12 High Level UI Event Handling12 High Level UI Event Handling
12 High Level UI Event Handling
 
Java Event Handling
Java Event HandlingJava Event Handling
Java Event Handling
 
Promises, promises, and then observables
Promises, promises, and then observablesPromises, promises, and then observables
Promises, promises, and then observables
 
Laboratory activity 3 b2
Laboratory activity 3 b2Laboratory activity 3 b2
Laboratory activity 3 b2
 
Angular js 2.0, ng poznań 20.11
Angular js 2.0, ng poznań 20.11Angular js 2.0, ng poznań 20.11
Angular js 2.0, ng poznań 20.11
 
Java scriptfunction
Java scriptfunctionJava scriptfunction
Java scriptfunction
 
Event handling
Event handlingEvent handling
Event handling
 
Redux with angular 2 - workshop 2016
Redux with angular 2 - workshop 2016Redux with angular 2 - workshop 2016
Redux with angular 2 - workshop 2016
 
Ms Ajax Dom Event Class
Ms Ajax Dom Event ClassMs Ajax Dom Event Class
Ms Ajax Dom Event Class
 
tL20 event handling
tL20 event handlingtL20 event handling
tL20 event handling
 
Windows Runtime Apps
Windows Runtime AppsWindows Runtime Apps
Windows Runtime Apps
 
JavaScript Essentials in 1 Hour (2018)
JavaScript Essentials in 1 Hour (2018)JavaScript Essentials in 1 Hour (2018)
JavaScript Essentials in 1 Hour (2018)
 
Introduction to Universal Apps-Jaliya Udagedara
Introduction to Universal Apps-Jaliya UdagedaraIntroduction to Universal Apps-Jaliya Udagedara
Introduction to Universal Apps-Jaliya Udagedara
 

Semelhante a Controls in action

For visual basicWhat should be the name of a button that has Name .pdf
For visual basicWhat should be the name of a button that has Name .pdfFor visual basicWhat should be the name of a button that has Name .pdf
For visual basicWhat should be the name of a button that has Name .pdf
feelinggifts
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshop
dhi her
 

Semelhante a Controls in action (20)

Basic iOS Training with SWIFT - Part 3
Basic iOS Training with SWIFT - Part 3Basic iOS Training with SWIFT - Part 3
Basic iOS Training with SWIFT - Part 3
 
iOS Development (Part 1)
iOS Development (Part 1)iOS Development (Part 1)
iOS Development (Part 1)
 
ITS-16163-Module 8-Graphic User Interface (GUI)
ITS-16163-Module 8-Graphic User Interface (GUI)ITS-16163-Module 8-Graphic User Interface (GUI)
ITS-16163-Module 8-Graphic User Interface (GUI)
 
GUI -THESIS123
GUI -THESIS123GUI -THESIS123
GUI -THESIS123
 
03_GUI.ppt
03_GUI.ppt03_GUI.ppt
03_GUI.ppt
 
DeprecatedAPI로 알아보는 SwiftUI
DeprecatedAPI로 알아보는 SwiftUIDeprecatedAPI로 알아보는 SwiftUI
DeprecatedAPI로 알아보는 SwiftUI
 
20180721 code defragment
20180721 code defragment20180721 code defragment
20180721 code defragment
 
Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2
 
Константин Чернухо_Popups, alerts and windows
Константин Чернухо_Popups, alerts and windowsКонстантин Чернухо_Popups, alerts and windows
Константин Чернухо_Popups, alerts and windows
 
The Ring programming language version 1.2 book - Part 34 of 84
The Ring programming language version 1.2 book - Part 34 of 84The Ring programming language version 1.2 book - Part 34 of 84
The Ring programming language version 1.2 book - Part 34 of 84
 
UIAutomation + Mechanic.js
UIAutomation + Mechanic.jsUIAutomation + Mechanic.js
UIAutomation + Mechanic.js
 
intro_gui
intro_guiintro_gui
intro_gui
 
The Ring programming language version 1.9 book - Part 71 of 210
The Ring programming language version 1.9 book - Part 71 of 210The Ring programming language version 1.9 book - Part 71 of 210
The Ring programming language version 1.9 book - Part 71 of 210
 
Jetpack Compose a nova forma de implementar UI no Android
Jetpack Compose a nova forma de implementar UI no AndroidJetpack Compose a nova forma de implementar UI no Android
Jetpack Compose a nova forma de implementar UI no Android
 
For visual basicWhat should be the name of a button that has Name .pdf
For visual basicWhat should be the name of a button that has Name .pdfFor visual basicWhat should be the name of a button that has Name .pdf
For visual basicWhat should be the name of a button that has Name .pdf
 
09events
09events09events
09events
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshop
 
Gui programming a review - mixed content
Gui programming   a review - mixed contentGui programming   a review - mixed content
Gui programming a review - mixed content
 
Silverlight as a Gaming Platform
Silverlight as a Gaming PlatformSilverlight as a Gaming Platform
Silverlight as a Gaming Platform
 
Autocad Training Delhi
Autocad Training DelhiAutocad Training Delhi
Autocad Training Delhi
 

Mais de SV.CO (20)

Handout level-1-module-1
Handout   level-1-module-1Handout   level-1-module-1
Handout level-1-module-1
 
Persistence And Documents
Persistence And DocumentsPersistence And Documents
Persistence And Documents
 
Building complex input screens
Building complex input screensBuilding complex input screens
Building complex input screens
 
Working with the Web: 
Decoding JSON
Working with the Web: 
Decoding JSONWorking with the Web: 
Decoding JSON
Working with the Web: 
Decoding JSON
 
Saving Data
Saving DataSaving Data
Saving Data
 
Alerts notification
Alerts notificationAlerts notification
Alerts notification
 
UI Dynamics
UI DynamicsUI Dynamics
UI Dynamics
 
Practical animation
Practical animationPractical animation
Practical animation
 
Segues and navigation controllers
Segues and navigation controllersSegues and navigation controllers
Segues and navigation controllers
 
Camera And Email
Camera And EmailCamera And Email
Camera And Email
 
Scroll views
Scroll viewsScroll views
Scroll views
 
Intermediate table views
Intermediate table viewsIntermediate table views
Intermediate table views
 
Table views
Table viewsTable views
Table views
 
Closures
ClosuresClosures
Closures
 
Protocols
ProtocolsProtocols
Protocols
 
App anatomy and life cycle
App anatomy and life cycleApp anatomy and life cycle
App anatomy and life cycle
 
Extensions
ExtensionsExtensions
Extensions
 
Gestures
GesturesGestures
Gestures
 
View controller life cycle
View controller life cycleView controller life cycle
View controller life cycle
 
Auto layout and stack views
Auto layout and stack viewsAuto layout and stack views
Auto layout and stack views
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 

Controls in action

  • 2. Controls • Buttons • Switches • Sliders • Text fields
  • 3. Buttons (UIButton) @IBAction func buttonTapped(_ sender: Any) // Code to respond to button }
  • 5. Switches (UISwitch) @IBAction func switchToggled(_ sender: UISwitch) { if sender.isOn { print("The switch is on!") } else { print("The switch is off.") } }
  • 6. Sliders (UISlider) @IBAction func sliderValueChanged(_ sender: UISlider) { print(sender.value) }
  • 7. Configuration Sliders (UISlider) Property Description Minimum Value Lowest number value the slider may represent Maximum Value Highest number value the slider may represent Current Starting number value the slider will represent Min Image Optional image on the minimum end of the slider Max Image Optional image on the maximum end of the slider
  • 8. Text fields (UITextField) @IBAction func keyboardReturnKeyTapped(_ sender: UITextField) { if let text = sender.text { print(text) } }
  • 9. Text fields (UITextField) Property Description Placeholder Text Text displayed when the text field is empty Text Text displayed by the text field Capitalization How the keyboard deals with capitalization Correction Enables or disables autocorrect Keyboard Which keyboard is displayed—for example, email, web, or default Return Key Text on the return key Secure Specific text fields that don't display their contents, commonly used for passwords
  • 10. Actions and outlets • @IBOutlet weak var toggle: UISwitch! • @IBOutlet weak var slider: UISlider! • @IBAction func buttonTapped(_ sender: UIButton) { • if toggle.isOn { • . . . • } • print(slider.value) • }
  • 11. Controls in Action Unit 2—Lesson 9 Use Interface Builder to add buttons, switches, and sliders to a scene Create actions and outlets, write some basic code, and gain an understanding of how these tools work together
  • 12. Lab: Basic Interactions Unit 2—Lesson 9 Create and compile an app with two buttons that, when tapped, change the contents of a label
  • 13. © 2017 Apple Inc. This work is licensed by Apple Inc. under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license.