Easy Tutorial
❮ Ios Camera Ios Location ❯

Introduction

Steps

  1. Let's use the first iPhone application.

  2. Select the ViewController.xib file from the navigation section.

  3. Choose UI elements from the library window displayed on the right side.

  4. Drag the UI elements into the visual box of the Interface Builder.

  5. Add a label and a red circular button to the visual view.

  6. Find the editor selection button in the upper right corner of the workspace toolbar, as shown below.

Select Editor Button

  1. There are two windows in the center of the editor area, ViewController.xib and ViewController.h.

  2. Right-click the selection button on the label, hold, and drag the new reference, as shown below.

  3. Now place it between the braces in ViewController.h. It can also be placed in the file, but must have been added before doing this, as shown below.

  4. Enter the outlet label name, here it is myTitleLabel. Click the link to complete the ibOutlet.

  5. Similarly, add an action by right-clicking the rounded rectangle, selecting the touch within and dragging it below the braces.

  6. Rename it to setTitleLabel.

  7. Select the ViewController.m file, and there is a method, as shown below.

    -(IBAction) setTitleLabel:(id)sender{
    }
    
  8. Within the above method, add a statement as shown below.

    [myTitleLabel setTitleText:@"Hello"];
    
  9. Select the run button to run the program, and get the following output.

  10. Click the button.

  11. The created reference (outlets) button label has been changed to the action (actions) performed on the button.

  12. As seen above, IBOutlet creates a reference to the UIElement (here, UILabel), and similarly, IBAction and UIButton are linked through performing actions and UIButton.

  13. When creating actions, you can perform different operations by selecting different events.

❮ Ios Camera Ios Location ❯