-
Notifications
You must be signed in to change notification settings - Fork 123
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
Different content view controllers #39
Comments
Hi, @PrakashMaharjan You can use any kind of class inheriting UIViewController to return value in PagingContentViewControllerDataSource Example:Declaring the values as UIViewControllerlet data: [(menu: String, content: UIViewController)] = [
(menu: "menu1", content: FooViewConotrller()),
(menu: "menu2", content: BarViewController())
] Declaring an associated value-type Enum for arbitrary typed UIViewControllers.enum ContentViewController {
case foo(vc: FooViewConotrller)
case bar(vc: BarViewConotrller)
var vc: UIViewController {
switch data[index].vc {
case .foo(let vc):
return vc
case .bar(let vc):
return vc
}
}
}
let data: [(menu: String, content: ContentViewController)] = [
(menu: "menu1", content: .foo(vc: FooViewConotrller())),
(menu: "menu2", content: .bar(vc: BarViewController()))
]
func numberOfItemsForContentViewController(viewController: PagingContentViewController) -> Int {
return data.count
}
func contentViewController(viewController: PagingContentViewController, viewControllerAt index: Int) -> UIViewController {
return data.content.vc
} If you have any question, feel free to ask me :) |
Hello, following this issue, I was able to load different viewcontrollers as datasource. But is there a way to replace the UI for the storyboard scene related to that ViewController in the PagingContentViewController? sorry if the question is too obvious. Thanks. |
How can we set content view controller with different view controllers for different index?
The text was updated successfully, but these errors were encountered: