ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalCOMP4126Using Textfields Butto…
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    COMP4126

    Mobile Application Development 2

    Progress0 / 38 done
    Topics38
    1Understanding Xcode2Using the Xcode interface builder and objects library3Understanding view hierarchy and creating a custom app icon
    4Understanding outlets and actions5Using text fields, buttons, labels, web views, and page controllers6Using views with subviews and creating views using code
    7Working with the single view template8Exploring the app delegate and adding new view controllers9Transitioning between multiple view controllers using animations
    10Tabbar and master detail templates
    11Customizing for different inputs12Adjusting text field behaviors and dismissing the keyboard13Detecting keyboard activities with notification center14Using scroll view and responding to keyboard activities programmatically
    15Detecting device hardware16Dynamically adjusting graphical layouts and creating universal apps
    17Understanding UITableView and UITableViewCell18Working with UITableView data source and delegate19Master detail template, drill-down menus, and navigation20Using property lists for data persistence and creating multi-section tables
    21Portrait and landscape modes22Handling device rotation and forcing specific orientation23Dynamically adjusting layouts based on rotation
    24Importing sqlite3 and creating a database25Writing tables, inserting records, and bundling a database with your app26Checking for database existence and reading/displaying data
    27NSTimer class and object transformations28Rotation, scaling, translation, animating image arrays, and playing video
    29Email, Safari, and SMS30Working with camera and photo library
    31Consuming and parsing XML and JSON32Integrating Twitter and Facebook with iOS apps
    33MapKit and MKMapView34Getting and displaying user location and directional information35Displaying map annotations, disclosure buttons, and reverse geocoding36Working with iCloud
    37Gyroscope and accelerometer38Outputting sensor data and using the Shake API
    3 min read
    Topic 5 of 38
    Topic Study Note Illustration
    05

    Using text fields, buttons, labels, web views, and page controllers

    These UI components are essential for building interactive iOS apps:

    πŸ“± Using Text Fields, Buttons, Labels, Web Views, and Page Controllers in iOS (Xcode)


    βœ… 1. Overview

    These UI components are essential for building interactive iOS apps:

    • Text Field β†’ User input
    • Button β†’ Trigger actions
    • Label β†’ Display text
    • Web View β†’ Display web content
    • Page Controller β†’ Swipe between screens

    🧠 2. Key UI Components


    πŸ”Ή 1. Text Field (UITextField)

    πŸ“Œ Definition

    A Text Field allows users to enter text input.

    πŸ“ Uses

    • Login forms (username, password)
    • Search bars

    βš™οΈ Example

    @IBOutlet weak var nameField: UITextField!
    
    let userName = nameField.text
    

    πŸ”Ή 2. Label (UILabel)

    πŸ“Œ Definition

    A Label displays read-only text.

    πŸ“ Uses

    • Titles
    • Messages
    • Output display

    βš™οΈ Example

    @IBOutlet weak var resultLabel: UILabel!
    resultLabel.text = "Welcome!"
    

    πŸ”Ή 3. Button (UIButton)

    πŸ“Œ Definition

    A Button is used to trigger an action when tapped.

    πŸ“ Uses

    • Submit forms
    • Navigate screens

    βš™οΈ Example

    @IBAction func submitPressed(_ sender: UIButton) {
        resultLabel.text = "Submitted!"
    }
    

    πŸ”Ή 4. Web View (WKWebView)

    πŸ“Œ Definition

    A Web View is used to display web pages inside the app.

    πŸ“ Uses

    • Open websites
    • Show online content

    βš™οΈ Example

    import WebKit
    
    @IBOutlet weak var webView: WKWebView!
    
    if let url = URL(string: "https://www.apple.com") {
        webView.load(URLRequest(url: url))
    }
    

    πŸ”Ή 5. Page Controller (UIPageViewController)

    πŸ“Œ Definition

    A Page Controller allows users to swipe between multiple screens/pages.

    πŸ“ Uses

    • App tutorials
    • Image sliders
    • Onboarding screens

    πŸ—οΈ 3. How They Work Together

    πŸ‘‰ Example Flow:

    1. User enters text in Text Field
    2. Presses Button
    3. Action triggered
    4. Result shown in Label
    5. Optional: Open link in Web View
    6. Navigate pages using Page Controller

    πŸ“Š Diagram Description (for Exams)

    Draw:

    TextField β†’ Button β†’ IBAction β†’ Label Update
                         ↓
                      WebView (optional)
                         ↓
                 Page Controller (multiple screens)
    

    βš™οΈ 4. Step-by-Step Implementation


    πŸ”Ή Step 1: Add UI Elements

    From Objects Library:

    • Drag:

      • Text Field
      • Label
      • Button
      • Web View

    πŸ”Ή Step 2: Connect Outlets

    @IBOutlet weak var textField: UITextField!
    @IBOutlet weak var label: UILabel!
    @IBOutlet weak var webView: WKWebView!
    

    πŸ”Ή Step 3: Add Button Action

    @IBAction func showText(_ sender: UIButton) {
        label.text = textField.text
    }
    

    πŸ”Ή Step 4: Load Web Content

    if let url = URL(string: "https://example.com") {
        webView.load(URLRequest(url: url))
    }
    

    πŸ”Ή Step 5: Setup Page Controller

    Basic steps:

    1. Create multiple view controllers
    2. Embed in UIPageViewController
    3. Enable swipe navigation

    πŸ“Œ 5. Important Rules / Tips

    • Use secure text entry for passwords
    • Always validate user input
    • Keep UI responsive with Auto Layout
    • Do not overload one screen with too many elements
    • Use Page Controller for better UX in tutorials

    πŸ’‘ 6. Example Application

    🎯 Simple Search App

    • Text Field β†’ Enter URL
    • Button β†’ Load page
    • Web View β†’ Display website
    @IBAction func loadWebsite(_ sender: UIButton) {
        if let text = textField.text,
           let url = URL(string: text) {
            webView.load(URLRequest(url: url))
        }
    }
    

    πŸ“ 7. Likely Exam Questions

    1. Define UITextField and its uses.
    2. What is UILabel? Explain with example.
    3. How does UIButton work in iOS?
    4. Explain WKWebView and its purpose.
    5. What is UIPageViewController?
    6. Write code to display text from TextField to Label.
    7. How do you load a webpage inside an app?
    8. Explain interaction between UI components.

    πŸ“š 8. Quick Revision Summary

    • Text Field β†’ Input
    • Label β†’ Output
    • Button β†’ Action trigger
    • Web View β†’ Display web pages
    • Page Controller β†’ Swipe between screens

    πŸ‘‰ Flow: User Input β†’ Button β†’ Action β†’ Output / Navigation


    ← Previous topic 4
    Outlets, Actions, and Views: Understanding outlets and actions
    Next topic 6 β†’
    Using views with subviews and creating views using code

    Past Papers

    Open this section to view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    3mremaining
    577words
    Beginnerlevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Mobile Application Development 2