ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Mobile Application Development 2
    COMP4126
    Progress0 / 38 topics
    Topics
    1. Creating an iOS App: Understanding Xcode2. Using the Xcode interface builder and objects library3. Understanding view hierarchy and creating a custom app icon4. Outlets, Actions, and Views: Understanding outlets and actions5. Using text fields, buttons, labels, web views, and page controllers6. Using views with subviews and creating views using code7. Using View Controllers: Working with the single view template8. Exploring the app delegate and adding new view controllers9. Transitioning between multiple view controllers using animations10. Application Templates: Tabbar and master detail templates11. The iOS Keyboard: Customizing for different inputs12. Adjusting text field behaviors and dismissing the keyboard13. Detecting keyboard activities with notification center14. Using scroll view and responding to keyboard activities programmatically15. Working with Different iOS Devices (iPhone & iPad): Detecting device hardware16. Dynamically adjusting graphical layouts and creating universal apps17. Using Table Views: Understanding UITableView and UITableViewCell18. Working with UITableView data source and delegate19. Master detail template, drill-down menus, and navigation20. Using property lists for data persistence and creating multi-section tables21. Supporting Screen Rotations: Portrait and landscape modes22. Handling device rotation and forcing specific orientation23. Dynamically adjusting layouts based on rotation24. Working with Databases: Importing sqlite3 and creating a database25. Writing tables, inserting records, and bundling a database with your app26. Checking for database existence and reading/displaying data27. Using Animations & Video: NSTimer class and object transformations28. Rotation, scaling, translation, animating image arrays, and playing video29. Accessing Integrated iOS Apps: Email, Safari, and SMS30. Working with camera and photo library31. Using Web Services: Consuming and parsing XML and JSON32. Integrating Twitter and Facebook with iOS apps33. Working with iOS Maps and Location Services: MapKit and MKMapView34. Getting and displaying user location and directional information35. Displaying map annotations, disclosure buttons, and reverse geocoding36. Working with iCloud37. Working with the Accelerometer: Gyroscope and accelerometer38. Outputting sensor data and using the Shake API
    COMP4126›Using text fields, buttons, labels, web views, and page controllers
    Mobile Application Development 2Topic 5 of 38

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

    3 minread
    577words
    Beginnerlevel

    📱 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 load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time3 min
      Word count577
      Code examples0
      DifficultyBeginner