Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Phone

Iphone Application : Using Gesture Recognizers (part 1)

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
11/8/2012 5:06:36 PM
Each gesture will update a text label with information about the gesture that has been detected. Pinch, rotate, and shake will take things a step further by scaling, rotating, or resetting an image view in response to the gestures.

Implementation Overview

This application, which we’ll name Gestures, will display a screen with four embedded views (UIView), each assigned a different gesture recognizer within the viewDidLoad method. When you perform an action within one of the views, it will call a corresponding method in our view controller to update a label with feedback about the gesture, and depending on the gesture type, update an onscreen image view (UIImageView), too.

The final application is shown in Figure 1.

Figure 1. The application will detect and act upon a variety of gestures.


Setting Up the Project

Start Xcode and create a new View-Based iPhone application called Gestures. Next, open up the GesturesViewController.h interface file and add outlets and properties for four UIViews: tapView, swipeView, pinchView, and rotateView. These are the views to which we’ll attach gesture recognizers. Add two additional outlets and properties, outputLabel and imageView, of the classes UILabel and UIImageView, respectively. These will be used to provide feedback to the user.

Listing 1 shows the finished interface file.

Listing 1.
#import <UIKit/UIKit.h>

@interface GesturesViewController : UIViewController {
    IBOutlet UIView *tapView;
    IBOutlet UIView *swipeView;
    IBOutlet UIView *pinchView;
    IBOutlet UIView *rotateView;
    IBOutlet UILabel *outputLabel;
    IBOutlet UIImageView *imageView;
}

@property (nonatomic, retain) UIView *tapView;
@property (nonatomic, retain) UIView *swipeView;
@property (nonatomic, retain) UIView *pinchView;
@property (nonatomic, retain) UIView *rotateView;
@property (nonatomic, retain) UIView *outputLabel;
@property (nonatomic, retain) UIImageView *imageView;

@end

To keep things nice and neat, edit the implementation file (GesturesViewController.m) to include @synthesize directives after the @implementation line:

@synthesize tapView;
@synthesize swipeView;
@synthesize pinchView;
@synthesize rotateView;
@synthesize outputLabel;
@synthesize imageView;

Finish off these preliminary steps by releasing each of these objects in the dealloc method of the view controller:

- (void)dealloc {
    [tapView release];
    [swipeView release];
    [pinchView release];
    [rotateView release];
    [outputLabel release];
    [imageView release];
    [super dealloc];
}

Adding the Image Resource

Before you can create your application’s gesture-aware interface, you need to add an image to the project. We will use this to provide visual feedback to the user. Included in this hour’s project’s Images folder is flower.png. Drag this file onto the Resources group for your project, choosing to copy it to the project, if needed, as shown in Figure 2.

Figure 2. Copy the flower.png image resource to the project. This will provide visual feedback to users.

Other -----------------
- Handling Input on Windows Phone 7 : Microphone Input
- Handling Input on Windows Phone 7 : Accelerometer
- XNA Game Studio 4.0 : XNA Game Studio Storage (part 2) - Getting a Device
- XNA Game Studio 4.0 : XNA Game Studio Storage (part 1) - Recreating the Project on Xbox, Devices and Containers
- XNA Game Studio 4.0 : Storage - Isolated Storage
- Using Media in XNA Game Studio : Visualizations
- Using Media in XNA Game Studio : Video
- XNA Game Studio 4.0 : Dynamic Sound Effects - Recording Audio with a Microphone, Generating Dynamic Sound Effects
- XNA Game Studio 4.0 : Playing Sound Effects (part 2) - Microsoft Cross-Platform Audio Creations Tool
- XNA Game Studio 4.0 : Playing Sound Effects (part 1) - Using SoundEffect for Audio Playback
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server