Comments (10)
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.
Thanks! any clue on how to do it with Swift?
from onboard.
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.
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.
What header files do you need to import for what, specifically?
from onboard.
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.
from onboard.
You need to create a UINavigationController
subclass, not UIViewController
.
from onboard.
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.
Yea, realized I had used ViewController rather than Navigation. I will take a look at the code. Thanks.
from onboard.
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)
- Change title of skip button HOT 1
- Crash if canceling a catch
- Skip Button not centralized in page control
- Multiple action buttons
- Open Onboard directly in storyboard HOT 2
- How change background image content mode?
- Changing Skip Button Size
- Dots don't show
- How to disable the onboardingViewController`s bounce
- iPhone X Support? HOT 6
- Project Continuity HOT 5
- How to hide a skip button in the last page? HOT 1
- How to change background image for every page ? HOT 1
- how to maintain the view of tab bar in the bottom?
- How can I add button right next to action button ?
- The picture has shifted downward.
- Use of '@import' when C++ modules are disabled, consider using -fmodules and -fcxx-modules @import AVKit;error
- Direct error reporting from import framework:Use of '@import' when C++ modules are disabled, consider using -fmodules and -fcxx-modules
- After adding, run the program and start the page black screen
- Why In my project, the images didn't fill the entire screen
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onboard.