stefanoa / SASlideMenu

Library to create iOS sliding menu compatible with storyboards
568 stars 118 forks source link

Menu is pushing ViewController down on startup #42

Closed XLW-Jeroen closed 11 years ago

XLW-Jeroen commented 11 years ago

Hello Stefanoa,

First of all, I'd like to say I really like this menu. It's been working great for months and we really appreciate your work on it.

We've been using the DynamicSlideMenu. However, since last week it suddenly isn't working properly anymore on startup.

I've added 3 screenshots.

The 1st screenshot shows what it looks like on startup (You can see the ViewController has been pushed down a bit and the top bar of the Menu is shown).

The 2nd screenshot shows the menu when you open the menu for the first time (You can still see that the ViewController on the right side is still pushed down a little bit).

On the 3rd screenshot you can see the ViewController as I've pressed a menu-item. As you can see, the ViewController now shows as it should.

Do you have any idea how to solve this? We have no idea how this problem has suddenly gotten into the App. If you need any additional info, please let me know.

Screen Shot 2013-02-20 at 2 05 09 PM Screen Shot 2013-02-20 at 2 07 16 PM Screen Shot 2013-02-20 at 2 05 33 PM

stefanoa commented 11 years ago

Hi Jeroen, I am happy you liked SASlideMenu and I am sorry you have problems now. Do you have the latest version? If not what version are you using?

stefanoa commented 11 years ago

If you are using the SASlideDynamicViewController it means that you are using an old version. In this case I suggest to update to the latest, if you can.

XLW-Jeroen commented 11 years ago

Hi Stefanoa,

Thankyou for the quick reply.

The first thing I tried was to update to a later version. However, I noticed the newest version doesn't have SASlideDynamicViewController anymore, so that is quite sad for us.

I currently don't know how much work it will be to start using a different method. Do you think updating to a newer version will help solving this problem? I just don't want it to be a waste of time.

stefanoa commented 11 years ago

There is something I do not understand. The problem is the initial space in the first screenshot that is solved only when the first selection is made?

XLW-Jeroen commented 11 years ago

Yes, exactly. It doesn't matter which ViewController I use as initial ViewController. It always happens on start-up and it's fixed when you make your first selection in the menu.

Also, what is the standard method of using the SlideMenu, since you discarded DynamicMenu?

stefanoa commented 11 years ago

I see. Now you have to subclass SASlideMenuViewController for both dynamic and static tables. There are also some changes to the SASlideMenuDataSource, there is an updated example that uses a dynamic table where you can check the differences. But I am not sure that your problem is related to the old version.

stefanoa commented 11 years ago

Do you have a simple project that recreate the problem? if you have it you can send it to me at:

email: stefano.ant [at] gmail.com skype: stefano.antonelli

XLW-Jeroen commented 11 years ago

Hi Stefanoa,

I don't currently have a simple project which recreates the problem. I do know that it is a iOS6+ related problem. The problem doesn't occur on iOS 5.1. We did have it working on iOS6.1 before though.

stefanoa commented 11 years ago

Try checking the frame when the ViewController is positioned at start-up. To do so you can replace the SASlideMenuDynamicViewController method slideToSide with:

-(void) slideToSide:(UINavigationController*) controller{
    CGRect bounds = self.view.bounds;
    CGFloat menuSize = [self menuSize];
    CGRect frame = CGRectMake(menuSize,0.0,bounds.size.width,bounds.size.height);
    NSLog(@"frame:%f,%f,%f,%f",frame.origin.x,frame.origin.y,frame.size.width,frame.size.height);
    controller.view.frame = frame;
}

What are you seeing at start-up and after the first menu selection? One more thing, have you enabled auto-layout ?

XLW-Jeroen commented 11 years ago

Hi Stefanoa,

Thanks again for your reply. I changed [self menuSize] to kMenuTableSize, because [self menuSize] wasn't recognized. The output is always: frame:280.000000,0.000000,320.000000,460.000000 I've got auto-layout turned off.

stefanoa commented 11 years ago

It seems ok, try adding also the view frame and bounds:


-(void) slideToSide:(UINavigationController*) controller{
    CGRect bounds = self.view.bounds;
    CGRect viewFrame = self.view.frame;
    CGFloat menuSize = kMenuTableSize;
    CGRect frame = CGRectMake(menuSize,0.0,bounds.size.width,bounds.size.height);
    NSLog(@"viewFrame:%f,%f,%f,%f",viewFrame.origin.x,viewFrame.origin.y,viewFrame.size.width,viewFrame.size.height);
    NSLog(@"bounds:%f,%f,%f,%f",bounds.origin.x,bounds.origin.y,bounds.size.width,bounds.size.height);
    NSLog(@"frame:%f,%f,%f,%f",frame.origin.x,frame.origin.y,frame.size.width,frame.size.height);
    controller.view.frame = frame;
}

In your screenshots the status bar is not present, do you cropped it?

XLW-Jeroen commented 11 years ago

Yes, I've cropped it in my screenshots. Here are the new logs (before and after): viewFrame:0.000000,20.000000,320.000000,460.000000 bounds:0.000000,0.000000,320.000000,460.000000 frame:280.000000,0.000000,320.000000,460.000000

stefanoa commented 11 years ago

Everything seems ok :-( Do you have Skype ? my id is: stefano.antonelli

XLW-Jeroen commented 11 years ago

I've added you on Skype.

stefanoa commented 11 years ago

After some investigation we found that the problem happens when calling **performSegueWithIdentifier* for the root controller in the **viewDidLoad* method of another view controller. It is better to use the viewDidAppear method instead.

williamoconnor commented 9 years ago

This is still a problem for me, even with the performSegueWithIdentifier call happening in viewDidLoad