Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

erdinc27

macrumors regular
Original poster
Jul 20, 2011
168
1
i want to open a left menu in the application that i develop. I can do it with a button but now the customer wants the left menu to be opened as much as the user panned the content view. For example the user panned content view 50 pix then i should open the left menu 50 pix. After a certain distance for example half of the content view's width i will open the left menu automatically. So i just want to know how much the user detected. I use such a code but it returns always 1 and 0
Code:
-(void)viewPanned:(UIPanGestureRecognizer *)sender {
   
   
    CGPoint rect = [sender translationInView:self.rightView];
   
    float currentX = rect.x;
   
    NSLog(@"View Panned %f", currentX - self.previousX);
   
    self.previousX = currentX;
}
 
What type of numbers do you get directly from the translationInView method? I would log those numbers out to the console and let us know what numbers you see.

By the way, you can also use the method 'locationInView' with self.view to get the coordinates IN the view. That way you know where in the view they are panning.
 
To be more clear i will write from start. SideBarbnbAnimation class was used in the project that i work on now. Customer wants the left menu to be opened by dragging main view also. Now it is opened only by a button. So i want to open the menu how much the user drags the main view. How it can be done ? May be i am on the wrong way by asking panning etc
 
To be more clear i will write from start. SideBarbnbAnimation class was used in the project that i work on now. Customer wants the left menu to be opened by dragging main view also. Now it is opened only by a button. So i want to open the menu how much the user drags the main view. How it can be done ? May be i am on the wrong way by asking panning etc
You can use UIView.animateWithDuration to change the X position of the sidebar's frame. Or you can use Core Animation, I've never really found many differences between the two performance-wise (I suspect the UIView animation methods are just another way of using CA but I'm not sure).

Depending on the X position of the users finger, you would tie the X position of the sidebar to the X position of their finger. If their finger goes too far, you might even put in a nice little snap-back animation instead of just abruptly stopping the sidebar pullout.

As far as the actual problem you are having, please make sure to read my previous post.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.