ios development (part 1)

18
iOS Development (Part I) COMPILED BY: ASIM RAIS SIDDIQUI ([email protected] )

Upload: asim-siddiqui

Post on 18-Nov-2014

627 views

Category:

Technology


3 download

DESCRIPTION

Familiarization with XCode, iOS Basic Controls, Actions and Properties. iPhone App Development Training Programme (contd.)

TRANSCRIPT

Page 1: iOS Development (Part 1)

iOS Development (Part I)COMPILED BY: ASIM RAIS SIDDIQUI([email protected])

Page 2: iOS Development (Part 1)

Goals of the Lecture

Familiarization with XCode IBOutlet & IBAction Types of Controls Common Properties of Xcode Controls

Handling Actions & Controls

Use of Text Fields, Labels, Sliders, Switch Buttons

Page 3: iOS Development (Part 1)
Page 4: iOS Development (Part 1)

Xcode Common Sections

The Toolbar

activity view

assistant view

Symbol navigator

Search navigator

Issues navigator

Page 5: iOS Development (Part 1)

The Toolbar

Page 6: iOS Development (Part 1)

Project Navigator

Page 7: iOS Development (Part 1)

Symbol navigator

Page 8: iOS Development (Part 1)

Issues navigator

Page 9: iOS Development (Part 1)

The Jump Bar

Page 10: iOS Development (Part 1)

What’s in the Nib File?

Every nib file starts off with the same two icons, File’s Owner and First Responder. They are created automatically and cannot be deleted.

Page 11: iOS Development (Part 1)

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 our nib file can be set up to trigger special methods in our controller class. These special methods are known as action methods (or just actions).

@property (nonatomic, retain) IBOutlet UIButton *myButton;

This example is an outlet called myButton, which can be set to point to any button in Interface Builder.

Page 12: iOS Development (Part 1)

Outlets and actions

Actions

In a nutshell, 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. The declaration for an action method will usually look like this:

- (IBAction)doSomething:(id)sender;

or like this:

- (IBAction)doSomething;

Page 13: iOS Development (Part 1)

Action with Multiple Buttons

- (IBAction)buttonPressed:(UIButton *)sender {

NSString *title = [sender titleForState:UIControlStateNormal]; statusText.text = [NSString stringWithFormat:@"%@ button pressed.", title];

}

Page 14: iOS Development (Part 1)

Practical

Page 15: iOS Development (Part 1)

Active, Static, and Passive Controls

Buttons : Active

ImageView : Static

Passive : TextField

Page 16: iOS Development (Part 1)

Some general control properties

Tag

Interaction Checkboxes

The Alpha Value

Background

Placeholder

Clear Button

Return Key popup

Auto Enable Return Key

Return key secure

Keyboard

Page 17: iOS Development (Part 1)

Handling actions with Controls

#import <UIKit/UIKit.h>

@interface BIDViewController : UIViewController

@property (strong, nonatomic) IBOutlet UITextField *nameField; @property (strong, nonatomic) IBOutlet UITextField *numberField;

- (IBAction)textFieldDoneEditing:(id)sender;

@end

- (IBAction)textFieldDoneEditing:(id)sender { [sender resignFirstResponder];

}

Page 18: iOS Development (Part 1)

Adding the Slider and Label

- (IBAction)sliderChanged:(id)sender {

UISlider *slider = (UISlider *)sender;

int progressAsInt = (int)roundf(slider.value);

sliderLabel.text = [NSString stringWithFormat:@"%d", progressAsInt];

}

The first line in the method assigns sender to a UISlider pointer so that the compiler will let us use UISlider methods and properties without warnings.