Clicky

Hi, I have a situation where the application has to work the same way that the activities that we do in Gesture to button event. I am using rotate and pinch gestures of view for rotating & zooming images. While the view is adjusted automaticaly the image which is inside the view is also getting adjusted automatically when we use gesture event. This application should use both the gesture & button event activities. If the user of the application is comfortable with the gesture then they can use the gesture, if they need to do a accurate adjustment to the image then they can use the button events like + to zoom in - to zoom out and < to rotate left and > to rotate right. The transformation used in button event to zoom or pinch should be same as gestures. While i am using the button event the transformation is reset to default position and then it is getting adjusted. I couldnt find a solution to do this. It would be helpfull if you can let me know ASAP.

Below is the code that i have used for Gesture:
 - (void)scalePiece:(UIPinchGestureRecognizer *)gestureRecognizer{     [self adjustAnchorPointForGestureRecognizer:gestureRecognizer];          if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged) {         [gestureRecognizer view].transform = CGAffineTransformScale([[gestureRecognizer view] transform], [gestureRecognizer scale], [gestureRecognizer scale]);         [gestureRecognizer setScale:1]; }   - (void)rotatePiece:(UIRotationGestureRecognizer *)gestureRecognizer{     [self adjustAnchorPointForGestureRecognizer:gestureRecognizer];          if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged) {         [gestureRecognizer view].transform = CGAffineTransformRotate([[gestureRecognizer view] transform], [gestureRecognizer rotation]);         [gestureRecognizer setRotation:0]; }    - (void)adjustAnchorPointForGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer {     if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {         viewForImage = gestureRecognizer.view;         CGPoint locationInView = [gestureRecognizer locationInView:viewForImage];         CGPoint locationInSuperview = [gestureRecognizer locationInView:viewForImage.superview];         viewForImage.layer.anchorPoint = CGPointMake(locationInView.x / viewForImage.bounds.size.width, locationInView.y / viewForImage.bounds.size.height);         viewForImage.center = locationInSuperview;     } }                             
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 

Select allOpen in new window

asked 08/23/2011 12:29

CGVAK's gravatar image

CGVAK ♦♦


8 Answers:
Could you please post your button event code that is causing the problem?
link

answered

darbid73's gravatar image

darbid73

Button Code as below:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
-(void)degereeleft
{
i=i-0.1;
CGAffineTransform transform = CGAffineTransformMakeRotation(i);
[viewForImage setTransform:transform];
[imageView setTransform:transform];
}

-(void)degereeright
{
i=i+0.1;
CGAffineTransform transform = CGAffineTransformMakeRotation(i);
[viewForImage setTransform:transform];
[imageView setTransform:transform];
}

-(void)zoomin
{
float w1 = viewForImage.frame.size .width+1;
float h1 = viewForImage.frame.size.height+1;
viewForImage.frame = CGRectMake(viewForImage.frame.origin.x, viewForImage.frame.origin.y, w1,h1);
imageView.frame = CGRectMake(imageView.frame.origin.x, imageView.frame.origin.y,  w1, h1);
}
-(void)zoomout
{
float w1 = viewForImage.frame.size .width-1;
float h1 = viewForImage.frame.size.height-1;
viewForImage.frame = CGRectMake(viewForImage.frame.origin.x, viewForImage.frame.origin.y, w1,h1);
imageView.frame = CGRectMake(imageView.frame.origin.x, imageView.frame.origin.y,  w1, h1);
}
link

answered 2011-08-24 at 21:39:38

CGVAK's gravatar image

CGVAK

is this ALL the code inside your IBAction for your button.
link

answered 2011-09-01 at 14:45:08

darbid73's gravatar image

darbid73

Yes.
link

answered 2011-09-03 at 12:16:10

CGVAK's gravatar image

CGVAK

That's impossible you cannot have multiple methods.
link

answered 2011-09-07 at 06:41:17

darbid73's gravatar image

darbid73

How do we solve this problem. Please advice.
link

answered 2011-09-07 at 08:55:56

CGVAK's gravatar image

CGVAK

I am not sure.  There is something in the event that occurs when you touch this button.  You need to show the exact code that is called when this button is touched.

In you .h you will have something like
1:
- (IBAction)yourButton:(id)sender;


Then in the .m file you will have this too.  I need this.

1:
2:
3:
4:
- (IBAction)yourButton:(id)sender
{

}


This is what is needed.  Please also put a break point in here and check it is actually called.
link

answered 2011-09-13 at 13:14:21

darbid73's gravatar image

darbid73

We will try and get back to you.
link

answered 2011-09-13 at 21:53:42

CGVAK's gravatar image

CGVAK

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×1
×1
×21
×42

Asked: 08/23/2011 12:29

Seen: 341 times

Last updated: 11/29/2011 12:02