Comments (2)
Hi
Reusable is totally able to do this, and StoryboardSceneBased
is indeed intended to be used exactly instantiate controllers designed in storyboards containing multiple scenes.
As explained in the README here (don't hesitate to click on the little black triangles to open the collapsed examples in that README btw), when you're using StoryboardSceneBased
, the name of the class is used by default to determine the sceneIdentifier
(and not the name of the *.storyboard
file), so in order for iOS to know from which *.storyboard
to extract that scene/controller, you'll need to explicitly provide a value for the sceneStoryboard
property in each class you mark conforming to StoryboardSceneBased
.
(StoryboardSceneBased
is probably the only protocol in the Reusable
library where not everything in the protocol has a default implementation, so this one is not really fully a "Mixin" per-se as you still have to provide that property explicitly)
class IntroViewController: StoryboardSceneBased {
static let sceneStoryboard = UIStoryboard(name: "Intro", bundle: nil)
}
class SplashViewController: StoryboardSceneBased {
static let sceneStoryboard = UIStoryboard(name: "Intro", bundle: nil)
}
class ViewController1: StoryboardSceneBased {
static let sceneStoryboard = UIStoryboard(name: "Main", bundle: nil)
}
class ViewController2: StoryboardSceneBased {
static let sceneStoryboard = UIStoryboard(name: "Main", bundle: nil)
}
…
PS: Note/Tip: to avoid repeating the string literals corresponding to the storyboard names and avoid making mistakes, I recommend to either:
- create namespaced constants for the
UIStoryboard
instances, ready to use them in each ViewController'sstatic let sceneStoryboard
implementation:
enum Storyboards {
static let intro = UIStoryboard(name: "Intro", bundle: nil)
static let main = UIStoryboard(name: "Main", bundle: nil)
}
class IntroViewController: StoryboardSceneBased {
static let sceneStoryboard = Storyboards.intro
}
class SplashViewController: StoryboardSceneBased {
static let sceneStoryboard = Storyboards.intro
}
…
- Or even better, use a tool like SwiftGen to auto-generate (and auto-maintain) those at build time (which actually also generates functions and constants to instantiate Storyboard-based ViewControllers in a type-safe way too, so that's an alternative solution to Reusable for that feature.
from reusable.
@AliSoftware Thanks a lot for the quick feedback!
from reusable.
Related Issues (20)
- getting error on using cellType(for indexPath:)
- Support for new API introduced on iOS 13
- MKMapView support
- Feature request - allow to use UITableViewCell with custom style
- Swift Package Manager: reusable deployment target warning HOT 3
- SPM xibs (Bundle.module) HOT 1
- Xcode 12.5 warnings HOT 2
- Swift tools version update too high, lower version build failed
- UITableViewHeaderFooterView - Warning with NibReusable
- Sure, go ahead!
- ## Summary
- Feature request - access to root xib view
- Support for reusable UITableViewHeaderFooterView subclasses?
- Privacy Manifest
- Swift 5 Support? HOT 2
- Undefined symbols when compiling for unit tests HOT 1
- Xcode 11 beta 4 compiler error HOT 1
- loadNibContent always loads nib named after base class HOT 14
- is there a way to override sceneStoryboard for StoryboardSceneBased HOT 2
- Swift Package Manager HOT 7
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 reusable.