Wednesday, January 15, 2014

touchesMoviedwithevent pictures or moving concrete realization point operations

touchesMoviedwithevent how to call the function, you need to include the header file, as well as where to add CODE, did not say why each is defined
Or point to achieve the specific operation to move the picture
Reply:
Such functions touchesMoviedwithevent four,
Is
respectively- (Void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event;
- (Void) touchesMoved: (NSSet *) touches withEvent: (UIEvent *) event;
- (Void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event;
- (Void) touchesCancelled: (NSSet *) touches withEvent: (UIEvent *) event;
These four functions in response to the event from the name can be seen, these four functions are defined in UIResponder rather UIViewController class is inherited from UIResponder class, so that any one of your project ViewController classes are subclasses can override these four functions, only need to. m your ViewController class (ie implementation file) overloading a function, you can handle this class corresponding event. Not need to declare. H (header file), the do not need any settings.
I immediately made up explains how to deal with these events.
Reply:
Write the following code in any function, you can get the location of the point where the event occurred
/ / Get current position of all touches
NSArray * touchArray = [touches allObjects];

/ / Show positon of each touch
for (UITouch * touch in touchArray)
{
CGPoint point = [touch locationInView: self.view];

}
Reply:
You can use the following code, respectively, the current double-click or click-click,
UITouch * touch = [touches anyObject];
int tapCount = [touch tapCount];
Reply:
- (Void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event;
For example, use this function, he said, did not define how it touchesBegan
Reply:
You are your own call this function? This function is defined. Under normal circumstances, do not call this function yourself.

Reply:
. H
@ Interface draw: UIView {
IBOutlet UITextField * textFied;
}
- (IBAction) vieMidText;
@ End
. M
- (Void) viewMidText {
CGPoint * point [[CGPoint alloc] init];
int mx = point.x;
int my = point.y;
textFied.text = @ "% d,% d", ma, my;

} I put the coordinates of the mouse to the middle of the screen display, what went wrong, and how to change it.
The above said, CGPoint not OBJECTIEVE_C CLASS NAME
Reply:
CGPoint's look at the definition, you will find CGPoint structure, not a class, so you can not use CGPoint * point = [[CGPoint alloc] init]; way.
CGPoint point; on it,
Of course, if you must use a pointer, then follow the way of the use of c language, (malloc and the like, you should understand what I'm saying)

No comments:

Post a Comment