Top Banner
Handling Basic Interaction [email protected] 1 Eng. Abdulrazzaq Alnajjar
21
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Beginning iOS6 Development CH03 Handlling Basic Interaction

Handling Basic Interaction

[email protected] 1Eng. Abdulrazzaq Alnajjar

Page 2: Beginning iOS6 Development CH03 Handlling Basic Interaction

The Model-View-Controller Paradigm

• Model-View-Controller (MVC) is a very logical way of dividing the code that makes up a GUI-based application.

• The MVC pattern divides all functionality into three distinct categories:– Model: The classes that hold your application’s data.– View: Made up of the windows, controls, and other

elements that the user can see and interact with.– Controller: The code that binds together the model

and view. It contains the application logic that decides how to handle the user’s inputs.

[email protected] 2Eng. Abdulrazzaq Alnajjar

Page 3: Beginning iOS6 Development CH03 Handlling Basic Interaction

Looking at the View Controller

• The Button Fun folder should contain four source code files (the ones that end in .h or .m) and a single nib file.

[email protected] 3Eng. Abdulrazzaq Alnajjar

Page 4: Beginning iOS6 Development CH03 Handlling Basic Interaction

Looking at the View Controller

• The controller class called BIDViewController is responsible for managing our application’s view.

• contents of the BIDViewController header file:

[email protected] 4Eng. Abdulrazzaq Alnajjar

Page 5: Beginning iOS6 Development CH03 Handlling Basic Interaction

Outlets and Actions

• A controller class can refer to objects in a nib file by using a special kind of property called an outlet.

• interface objects in nib file can be set up to trigger special methods in controller class. These special methods are known as action methods.

[email protected] 5Eng. Abdulrazzaq Alnajjar

Page 6: Beginning iOS6 Development CH03 Handlling Basic Interaction

Outlets

• Outlets are special Objective-C class properties that are declared using the keyword IBOutlet.

[email protected] 6Eng. Abdulrazzaq Alnajjar

Page 7: Beginning iOS6 Development CH03 Handlling Basic Interaction

Actions

• Actions are methods that are declared with a special return type, IBAction, which tells Interface Builder that this method can be triggered by a control in a nib file.

[email protected] 7Eng. Abdulrazzaq Alnajjar

Page 8: Beginning iOS6 Development CH03 Handlling Basic Interaction

User Interface

[email protected] 8Eng. Abdulrazzaq Alnajjar

Page 9: Beginning iOS6 Development CH03 Handlling Basic Interaction

Buttons and Action Method

1) Object library

2) Round Rect Button.(Drag)

3) View (Drop)

4) Edit the button’s title.

5) Show the Assistant Editor.

[email protected] 9Eng. Abdulrazzaq Alnajjar

Page 10: Beginning iOS6 Development CH03 Handlling Basic Interaction

Buttons and Action Method

6) Control-dragging to source code

[email protected] 10Eng. Abdulrazzaq Alnajjar

Page 11: Beginning iOS6 Development CH03 Handlling Basic Interaction

Buttons and Action Method

7) Connection: Action, Name: buttonPressed, Press connect.

[email protected] 11Eng. Abdulrazzaq Alnajjar

Page 12: Beginning iOS6 Development CH03 Handlling Basic Interaction

Buttons and Action Method

[email protected]

8) Header file should now look like this:

12Eng. Abdulrazzaq Alnajjar

Page 13: Beginning iOS6 Development CH03 Handlling Basic Interaction

Buttons and Action Method

9) Impelementation file added a method stub

[email protected] 13Eng. Abdulrazzaq Alnajjar

Page 14: Beginning iOS6 Development CH03 Handlling Basic Interaction

Label and Outlet

• Adding outlet to label

[email protected] 14Eng. Abdulrazzaq Alnajjar

Page 15: Beginning iOS6 Development CH03 Handlling Basic Interaction

Label and Outlet

• header file after adding outlet

[email protected] 15Eng. Abdulrazzaq Alnajjar

Page 16: Beginning iOS6 Development CH03 Handlling Basic Interaction

Action Method

[email protected] 16

Take the title of the button

Put the title in a string

Equal the string to the label

Eng. Abdulrazzaq Alnajjar

Page 17: Beginning iOS6 Development CH03 Handlling Basic Interaction

Application Delegate

• Objects that take responsibility for doing certain tasks on behalf of another object.

• Every iOS application has one, and only one.

[email protected] 17Eng. Abdulrazzaq Alnajjar

Page 18: Beginning iOS6 Development CH03 Handlling Basic Interaction

AppDelegate.h File

[email protected] 18Eng. Abdulrazzaq Alnajjar

Page 19: Beginning iOS6 Development CH03 Handlling Basic Interaction

AppDelegate.m File

[email protected] 19Eng. Abdulrazzaq Alnajjar

Page 20: Beginning iOS6 Development CH03 Handlling Basic Interaction

AppDelegate.m File

[email protected] 20Eng. Abdulrazzaq Alnajjar

Page 21: Beginning iOS6 Development CH03 Handlling Basic Interaction

AppDelegate.m File

[email protected] 21Eng. Abdulrazzaq Alnajjar