TheSidebarController icon indicating copy to clipboard operation
TheSidebarController copied to clipboard

Modal presentation issue

Open Dids opened this issue 10 years ago • 12 comments

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 avatar Sep 15 '14 17:09 Dids

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 [email protected], wrote: Hi @Dids

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

Jon

Dids avatar Sep 16 '14 08:09 Dids

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

ngoccuong291 avatar Oct 19 '14 12:10 ngoccuong291

@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

Dids avatar Oct 19 '14 13:10 Dids

@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.

ngoccuong291 avatar Oct 19 '14 13:10 ngoccuong291

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.

joaofranca avatar Oct 22 '14 12:10 joaofranca

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.

ngoccuong291 avatar Oct 24 '14 03:10 ngoccuong291

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 avatar Oct 25 '14 13:10 dayjer

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

dayjer avatar Oct 25 '14 14:10 dayjer

storyboardsUseAutoLayout to YES appears to break rotation.

dayjer avatar Oct 28 '14 06:10 dayjer

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.

wuleijun avatar Jul 04 '15 03:07 wuleijun

did you try with? sidebarController.translatesAutoresizingMaskIntoConstraints = YES;

That worked for my

juancruzmdq avatar Jul 14 '15 22:07 juancruzmdq

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

panol avatar Jul 10 '16 06:07 panol