Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface orientation iPhone/iPad in injected view controllers #483

Open
jcmartinac opened this issue Mar 7, 2016 · 4 comments
Open

Interface orientation iPhone/iPad in injected view controllers #483

jcmartinac opened this issue Mar 7, 2016 · 4 comments

Comments

@jcmartinac
Copy link

Hi, I have a problem injecting my initial view controller (a navigation with a view controller as root) when I run it in landscape orientation.

The app should run portrait in iPhone and landscape in iPad, but only iPhone render well. In iPad starts rotated, and looks like size classes aren't working, because I can see a black background. Link to image:

https://www.dropbox.com/s/tqqca444ooe9gkj/Captura%20de%20pantalla%202016-03-07%20a%20las%2010.49.37.png?dl=0

And this is mi code to inject the initial viewcontroller:

  • (UIWindow *) mainWindow {
    return [TyphoonDefinition withClass:[UIWindow class] configuration:^(TyphoonDefinition *definition)
    {
    [definition useInitializer:@selector(initWithFrame:) parameters:^(TyphoonMethod *initializer)
    {
    [initializer injectParameterWith:[NSValue valueWithCGRect:[[UIScreen mainScreen] bounds]]];
    }];
    [definition injectProperty:@selector(rootViewController) with:[self rootViewController]];
    }];
    }
  • (UINavigationController *) rootViewController {
    return [TyphoonDefinition withClass:[UINavigationController class] configuration:^(TyphoonDefinition *definition)
    {
    [definition useInitializer:@selector(initWithRootViewController:) parameters:^(TyphoonMethod *initializer)
    {
    [initializer injectParameterWith:[self viewController]];
    }];
    }];
    }
  • (ViewController *) viewController {
    return [TyphoonDefinition withClass:[ViewController class] configuration:^(TyphoonDefinition *definition)
    {
    [definition injectProperty:@selector(assembly) with:self];
    }];
    }

Looking into documentation and forums, I have not found any help. Am I forgetting something?

@jcmartinac
Copy link
Author

It looks that the problem comes from init the main window frame in the assembly, because it doesn't set it properly. (In simulator doesn't work at all)
When I set the main window frame in the appDelegate didFinishLaunchingWithOptions like this:
self.window.frame = [UIScreen mainScreen].bounds;
it works fine, but with another problem: the device rotation doesn't work... Any idea?

@alexgarbarev
Copy link
Contributor

Hm.. Typhoon just instantiates ViewControllers and Windows for you. It's similar like if you create it on your own somewhere in another place. So it's not Typhoon problem, but something with UIKit configuration. ( UIKit is magic box - results are often unknown)

For your case, I would recommend using UIStoryboard as entry point, since it's standard approach now in iOS. Typhoon works with UIStoryboard very well

@niphlhell
Copy link

niphlhell commented Jun 23, 2016

I have the same issue, and if create window at didFinishLaunchingWithOptions

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = self.rootViewController;

all works as expected.

such code do not work as expected. The same black line and no rotations

- (UIWindow *)mainWindow {
    return [TyphoonDefinition withClass:[UIWindow class] configuration:^(TyphoonDefinition * definition) {
        [definition useInitializer:@selector(initWithFrame:) parameters:^(TyphoonMethod * initializer) {
            [initializer injectParameterWith:[NSValue valueWithCGRect:[[UIScreen mainScreen] bounds]]];
        }];
        [definition injectProperty:@selector(rootViewController) with:[self rootViewController]];
    }];
}

@jasperblues
Copy link
Member

The Typhoon sample app exhibited the same issue, so the window was created with code inside the app delegate: https://github.com/appsquickly/Typhoon-Swift-Example

Interestingly, this problem does not occur with the Objective-C version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants