Giter Site home page Giter Site logo

Landscape Mode? about onboard HOT 10 CLOSED

inadeem avatar inadeem commented on July 24, 2024
Landscape Mode?

from onboard.

Comments (10)

mamaral avatar mamaral commented on July 24, 2024

No landscape support. In the past I've subclassed UINavigationController and added the following:

#import "NonRotatingNavigationController.h"

@interface NonRotatingNavigationController ()

@end

@implementation NonRotatingNavigationController

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

- (BOOL)shouldAutorotate {
    return NO;
}

@end

from onboard.

inadeem avatar inadeem commented on July 24, 2024

Thanks! any clue on how to do it with Swift?

from onboard.

mamaral avatar mamaral commented on July 24, 2024

Swift could should be virtually identical to this, other than the minor syntax differences. Just implement those two methods and return those two values in a subclassed navigation controller.

from onboard.

inadeem avatar inadeem commented on July 24, 2024

Not sure what header files to import, or even if I have to. hmm

I used a lot of the code from Seanicus' repo. He forked yours. No header files in that one.

from onboard.

mamaral avatar mamaral commented on July 24, 2024

What header files do you need to import for what, specifically?

from onboard.

inadeem avatar inadeem commented on July 24, 2024

I'm looking at your code and I see that you imported some header files.

I created a new View controller, and subclassed it as UIViewController. Not sure how to link up the onBoard walkthrough pages..Created a new Swift file and this is the boilerplate code that comes with the file.

screen shot 2015-08-04 at 10 53 25 pm

from onboard.

mamaral avatar mamaral commented on July 24, 2024

You need to create a UINavigationController subclass, not UIViewController.

from onboard.

mamaral avatar mamaral commented on July 24, 2024

Then, in your app delegate, you want something like this:

OnboardingContentViewController *firstPage = [OnboardingContentViewController contentWithTitle:title body:body image:image buttonText:buttonText  action:^{
    // action if you want one
}];

OnboardingContentViewController *secondPage = [OnboardingContentViewController contentWithTitle:title body:body image:image buttonText:buttonText  action:^{
    // action if you want one
 }];

OnboardingContentViewController *thirdPage = [OnboardingContentViewController contentWithTitle:title body:body image:image buttonText:buttonText  action:^{
    // action if you want one
}];

OnboardingViewController *onboardingVC = [OnboardingViewController onboardWithBackgroundImage:image contents:@[firstPage, secondPage, thirdPage]];
NonRotatingNavigationController *nc = [[NonRotatingNavigationController alloc] initWithRootViewController:onboardingVC];
self.window.rootViewController = nc;

Porting that to swift should be easy and this should be enough to get you started. If you need any more help, I'd advise going through the demo project and learning how it works, there are multiple examples there, and like I said swift is similar enough to objective-c that you should be able to figure it out by looking at the examples.

from onboard.

inadeem avatar inadeem commented on July 24, 2024

Yea, realized I had used ViewController rather than Navigation. I will take a look at the code. Thanks.

from onboard.

inadeem avatar inadeem commented on July 24, 2024

This is what I used to get it to go to Landscape mode. Added this code in the onBoardingViewController.Swift file! Still a bit bugy but it seems to be OK for right now.

//**********

    override func viewWillAppear(animated: Bool)
    {
        let value = UIInterfaceOrientation.Portrait.rawValue
        UIDevice.currentDevice().setValue(value, forKey: "orientation")

    }

override func shouldAutorotate() -> Bool {
    // Lock autorotate
    return false
}

override func supportedInterfaceOrientations() -> Int {

    // Only allow Portrait
    return Int(UIInterfaceOrientationMask.Portrait.rawValue)
}

override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {

    // Only allow Portrait
    return UIInterfaceOrientation.Portrait
}

//**********

from onboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.