jondanao / TheSidebarController

A container view controller that implements different popular sidebar view controllers like Facebook, Airbnb, Flipboard, etc.
Other
360 stars 52 forks source link

Modal presentation issue #12

Open Dids opened 10 years ago

Dids commented 10 years ago

Presenting a modal view controller from either TheSidebarController or the main content controller works, but when the modal view controller is dismissed, TheSidebarController (and the sidebar and main content controller) are no longer visible, and all that's left is the UIWindow background color.

I've tried this multiple times and seem to be able to replicate it 100% of the time.

Ideally, I'd like to be able to get the top most view controller (TheSidebarController in this case) and present a modal view controller from it, without any problems.

EDIT: This issue affects both iOS 7 and iOS 8.

Dids commented 10 years ago

I can’t seem to see your comment on the GitHub page, but no, I can’t present a modal view controller from self.sideBarController or the contentViewController.

— Pauli Jokela

Jon Danao notifications@github.com, wrote: Hi @Dids

Can you present the modal from [self.sidebarController presentViewController.....]?

Jon

ngoccuong291 commented 9 years ago

I got the same issue. Is this issue fixed? @Dids did you find a solution for it?

Dids commented 9 years ago

@ngoccuong291

This library doesn't seem to be well maintained, so I gave up on it, after not being able to track down exactly what causes the issue.

My solution was to move to a more maintained a lot more stable solution: https://github.com/John-Lluch/SWRevealViewController

ngoccuong291 commented 9 years ago

@Dids Thanks, I will give it a try when I have free time but at the moment, I will also need to choose a stable solution.

joaofranca commented 9 years ago

I found a way to avoid this problem - in your app delegate, didFinishLaunchingWithOptions add this [[self window] addSubview:sidebarController.view].

The 'window' set block should look like this:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor blackColor];
[[self window] setRootViewController:sidebarController];
[[self window] addSubview:sidebarController.view]; // THIS!
[self.window makeKeyAndVisible];

It solved the problem for me.

ngoccuong291 commented 9 years ago

Thanks @joaofranca I can confirm that the hack worked but I'm not 100% sure about the side effect of this hack because from iOS 4, Apple encouraged developers to set the rootViewController instead of addSubView to UIWindow. For now, everything is good.

dayjer commented 9 years ago

This hack doesn't work for me (just leaves me with a black window). I'm stuck on this as well after several hours debugging led me here.

dayjer commented 9 years ago

Discovered "storyboardsUseAutoLayout" BOOL -- solved my issue. Not that I'm using storyboards..!

dayjer commented 9 years ago

storyboardsUseAutoLayout to YES appears to break rotation.

wuleijun commented 9 years ago

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor blackColor]; [[self window] setRootViewController:sidebarController]; [[self window] addSubview:sidebarController.view]; // THIS! [self.window makeKeyAndVisible];

It solved the problem for me.

juancruzmdq commented 9 years ago

did you try with? sidebarController.translatesAutoresizingMaskIntoConstraints = YES;

That worked for my

panol commented 8 years ago

@joaofranca now that you have solved this problem,do you know why does work?