3

I'm developing a application using ECSliding framework. Everything was going well until I add a UItableViewController as the topViewController. I'm facing an error while trying to scroll the static table view. I could identify where is the problem but I don't know how to solve it. If I delete the command bellow (declared at viewDidLoad method), my UITableView starts to scroll normally.

 [self.view addGestureRecognizer:self.slidingViewController.panGesture];

Code used to set the UITableViewController as the topViewController

 self.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Driver"];

topViewController is a property from the ECSlidingViewController

I have found another similar question on another post, but there, the guy was using a UINavigationController as the topViewController.

Please let me know if someone can give me a hand.

thanks, Marcos.

vilelam
  • 804
  • 1
  • 11
  • 19
  • A quick advice man, why don't you post the code you used to add the tableviewcontroller as top view. And also the crash log or the error report so we can provide some help. – Adrian P Mar 30 '13 at 02:45
  • @CodeMonkey Thanks for your quick reply and the advice. I've added the code used to set the UItableViewController as the topViewController. There is no log, the only problem is that the UITable View doesnt scroll. – vilelam Mar 30 '13 at 03:23
  • I haven't seen that library yet, but there is a grand possibility that there is something involved with our IB. Check the attributes of the scroll view in your IB. If I get some time i will download the control and plug n a tableview as top view and see what happens. – Adrian P Mar 30 '13 at 03:46
  • i just downloaded the control and replaced the first top view in storyboard with a uitableview controller by deleting it. then i set the storyboard identifier to the whatevertop which was the name of the tableview controller and made sure that in menu view controller i replaced the Fist with the whatever which was the name of the class and it compiles fine and scrolls greatly as well. no need to delete anything. i think your problem lies elsewhere. when replacing the topviewcontroller, make sure you follow the same steps i did. – Adrian P Mar 30 '13 at 13:08
  • 1
    @CodeMonkey I have also downloaded the ECSliding framework again creating a new test project. I have changed the MainViewController to a UITableViewController, but as soon as it is set to the topViewController it doesn't scroll. – vilelam Mar 30 '13 at 15:11
  • @CodeMonkey Now I'm asking myself if it make sense, to have a horizontal pangesture and a vertical scroll enabled. In the facebook App we only have the vertical scroll and when the menu is needed you have to press the menu button. No horizontal PanGesture is available. – vilelam Mar 30 '13 at 15:14
  • It is true. In the library I wrote for one of projects I just used the buttons to move the menu right and left. You may have to do that or just disable the horizontal view in top menu and allow all others to have it. – Adrian P Mar 30 '13 at 15:30
  • I found the solution at this [post][1] [1]: http://stackoverflow.com/questions/10967484/how-to-make-the-tableview-response-pan-gesture-in-zuuirevealcontroller – vilelam Mar 30 '13 at 23:01
  • I am glad you did find the solution so you can get back to coding. Have fun my friend – Adrian P Mar 31 '13 at 00:36
  • @vilelam how did you solve it? I have the same issue, I have a tableview and it doesn't want to scroll but if I delete that line it works. What do I have to do instead of deleting that line? Or if I delete that it's ok? – Carmichael Apr 25 '13 at 11:17

1 Answers1

1

I see that you solved your issue but per-comments other people are looking for this solution as well, so I will give some information about this.

The problem here is that when you add a pan gesture to the UITableView subclass it messes with the current gestures used for scrolling. When you pan it no longer knows what you are after and you can end up with inconsistent behavior (or behavior you did not want).

There are a couple of different solutions that may work pending on your actual needs:


ONE:

If you become UIGestureRecognizerDelegate you can implement the method:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return TRUE;
}

This allows you to listen for multiple gestures. Just make sure you set your gesture's delegate to self

TWO:


If you specify what direction you want the new gesture to implement you may cease having scrolling problems:

   UISwipeGestureRecognizer* swipe;

   swipe = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeL)] autorelease];
   swipe.direction = UISwipeGestureRecognizerDirectionLeft;
   [view addGestureRecognizer:swipe];

   swipe = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeR)] autorelease];
   swipe.direction = UISwipeGestureRecognizerDirectionRight; // default
   [view addGestureRecognizer:swipe];

Obviously this is using a swipe, but it could easily be modified. This says that you do not want to worry about vertical gestures and you can allow the table to continue its default behavior. You may still need to implement the delegate method in ONE though, to verify that it listens for multiple gestures.

Community
  • 1
  • 1
Firo
  • 15,448
  • 3
  • 54
  • 74