Text Input Practice Set

Ace your homework & exams now with Quizwiz!

What are the 3 steps to becoming the delegate of a UITextField?

1. Adopt the UITextFieldDelegate (for example: class MyViewController: UIViewController, UITextFieldDelegate) 2) Set the delegate property of the text field (in viewDidLoad, for example: self.textField.delegate = self) 3) Implement whichever methods on UITextFieldDelegate you want.

What are the 3 steps to becoming the delegate of a UITextView?

1. Adopt the UITextViewDelegate (for example: class MyViewController: UIViewController, UITextViewDelegate) 2) Set the delegate property of the text field (in viewDidLoad, for example: self.textView.delegate = self) 3) Implement whichever methods on UITextViewDelegate you want.

What is the placeholder text of a UITextField?

It is the grayed out text that shows up in a text field before the user starts typing into the field.

Does a UILabel support text input?

No

How do I change the text on the return / enter button for the keyboard of a UITextField?

The returnType property

What does this block of code do? let center = NotificationCenter.default center.addObserver(self, selector: #selector(keyboardWillShow), name: .UIKeyboardWillShow, object: nil) center.addObserver(self, selector: #selector(keyboardWillHide), name: .UIKeyboardWillHide, object: nil)

This causes the functions keyboardWillShow and keyboardWillHide to get called the keyboard shows and hides. If you do not have this function, your keyboardWillShow and keyboardWillHide functions will never get called.

What does this block of code do? let frame = (notification.userInfo![UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue

This gets the frame of the keyboard out of an NSNotification object. This line of code can be used inside your keyboardWillShow or keyboardWillHide functions.

True or False: I can control the font size of the text inside of a UITextView.

True

Between UITextView and UITextField, which one supports multiple lines of text?

UITextView

How do you change the color of text inside of a UITextField?

Use the textColor property, like this: textField.textColor = UIColor.red

How do you change the color of text inside of a UITextView?

Use the textColor property, like this: textView.textColor = UIColor.blue

How do you access the current text that is in a UITextField?

Using its .text property, like this: myField.text

How do you access the current text that is in a UITextView?

Using its .text property, like this: myTextView.text

Which method on the UITextViewDelegate protocol gets called when the user taps and activates the UITextView?

func textViewDidBeginEditing(_ textView: UITextView)

Which method on the UITextViewDelegate protocol gets called when the user is done typing into a UITextView?

func textViewDidEndEditing(_ textView: UITextView)

Let's say I have a UITextField in a variable called myField. How can I change its keyboard to only show numbers?

myField.keyboardType = .numberPad


Related study sets

Ch. 16 Other Descriptive Research Methods

View Set

Recruitment & Selection - Final Exam

View Set

Anatomy Ch. 15 Urinary System Quiz

View Set

Evolve - Med Surg - Renal & Repro

View Set

Ch 6: consolidation of Variable Interest Entities and Other Intracompany Investments

View Set

Introduction to two-way tables copy (real one)

View Set