Tech-Today
iPhone touch event programming stanford's stalker project
Moving on with Stanford's set of exercise, here I am working on how to handle iPhone's touch events. I will replicate the Stalker class created by Paul?
Steps:
1.) Create a new WIndow-based Application project, Stalker
2.) Create a new class TouchResponder
TouchResponder.h
#import <UIKit/UIKit.h>
@interface TouchResponder : UIView {
IBOutlet UIView *stalker;
}
@end
TouchResponder.m
#import "TouchResponder.h"
@implementation TouchResponder
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[UIView beginAnimations:@"stalk" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationBeginsFromCurrentState:YES];
UITouch *touch = [touches anyObject];
stalker.center = [touch locationInView:self];
[UIView commitAnimations];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
}
@end
2.) Open the interface builder, locate the UIView from the library and drag and drop to the window
a.) Open the view's Identity Inspector and change the class to: TouchResponder
3.) Repeat step 2, while the second view is selected make the following changes:
a.) In the Attributes Inspector, set the Background color to red
b.) In the Size Inspector, x=0, y=0, w=20, h=20
4.) Finally, we will link the first view to the stalker outlet by clicking on the large view and move the cursor to the small view.
5.) stalker outlet should show
-
Webview Tutorial In Ios 8 With Swift
The UIWebView class is use to embed web content in an application. It can be done by simply creating a UIWebView object and attaching it to a window and then sending it a request to load web content. Open Xcode and create a new Single View Application....
-
Create An Image Slide Show In Iphone Using Xcode
Here's how you can create image slide show from xcode - iphone Requirement: -3 png images. 1.) Create a new View-based application project. Name it AnimationDemo. 2.) Once the new project is created. Add the 3 png images to the Resources folder....
-
Iphone Xcode - Create A Simple Uiscrollview
Finally getting acquainted with iPhone's xcode. Now I'll build a simple window base application to demo the UIScrollView features. 1.) Create a new window base application, named it MyScroll. It should create 2 files: a.) MyScrollAppDelegate.h...
-
Iphone Xcode - How To Create A Simple Uitabbar
A simple demonstration by code on how to implement a UITabBar on iPhone. 1.) Create a new Windows based project, and named it whatever you want. 2.) You should look up for 2 files, .h and .m (I named mine MyTab). MyTabAppDelegate.h #import <UIKit/UIKit.h>...
-
Iphone Development Making The Slider Control Work
Lately I've been trying to learn iPhone development by following tutorials available online. But I often encountered problems building and running, even though I'm sure I've followed the tutorial perfectly. For example, I was following a simple...
Tech-Today