I have 3 view (UIViewController). I want to do 3d cube as like this Link. But this link project have using by objective C but I need swift language. Please can I get resource for this project. I am trying to use Bridging-Header.h but not working!!
My Code Bellow:
import UIKit
class SecondViewController: CubeController, CubeControllerDataSource, CubeControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfViewControllersInCubeController(cubeController: CubeController!) -> Int {
return 3
}
func cubeController(cubeController: CubeController!, viewControllerAtIndex index: Int) -> UIViewController! {
switch(index % 3){
case 0:
return AViewController(nibName: "MyViewController", bundle: nil)
case 1:
return BViewController()
case 2:
return CViewController()
default:
return nil
}
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
You have to use the bridging header for this classes :
Sample code with swift integration :
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, CubeControllerDataSource {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow.init(frame: UIScreen.mainScreen().bounds)
let cubeVC : CubeController = CubeController()
cubeVC.dataSource = self
cubeVC.wrapEnabled = true
self.window?.rootViewController = cubeVC
self.window?.makeKeyAndVisible()
// Override point for customization after application launch.
return true
}
func numberOfViewControllersInCubeController(cubeController: CubeController!) -> Int {
return 3
}
func cubeController(cubeController: CubeController!, viewControllerAtIndex index: Int) -> UIViewController! {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
switch (index % 3){
case 0:
return storyboard.instantiateViewControllerWithIdentifier("VC1")
case 1:
return storyboard.instantiateViewControllerWithIdentifier("VC2")
case 2:
return storyboard.instantiateViewControllerWithIdentifier("VC3")
default:
return nil
}
}
}