StefanLage / SLPagingViewSwift

Navigation bar system allowing to do a Tinder like or Twitter like. SLPagingViewSwift is a Swift port of the Objective-C of SLPagingView
MIT License
215 stars 35 forks source link

TableView in controller #3

Open baoluo opened 9 years ago

baoluo commented 9 years ago

There is a problem when embedding a tableView in a controller.

It will display it, but as soon as we touch the view the TV will disappear

mario1in commented 9 years ago

I have the same problem , how do you fix it?

baoluo commented 9 years ago

I used ViewControllers instantiation via Storyboard, and it worked. But I dropped SLPaging as I wasn't able to push within the controller.

codinglearning commented 9 years ago

I'm using it with storyboard, but still doesn't work :S any solution?

baoluo commented 9 years ago

I ended up using SLPagiung this way :

(AppDelegate)

var window: UIWindow? var nav: UINavigationController? var controller: SLPagingViewSwift? var profileTableViewController: ProfileTableViewController?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch.

self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
var orange = UIColor(red: 255/255, green: 69.0/255, blue: 0.0/255, alpha: 1.0)
var gray = UIColor(red: 0.84, green: 0.84, blue: 0.84, alpha: 1.0)

let storyboard = UIStoryboard(name: "Main", bundle: nil)

profileTableViewController = storyboard.instantiateViewControllerWithIdentifier("SNPMTCH.profile") as? ProfileTableViewController

var homeViewController = storyboard.instantiateViewControllerWithIdentifier("SNPMTCH.home") as! UIViewController
homeViewController.title = "Home"
homeViewController.view.backgroundColor = UIColor.yellowColor()

var chatViewController = storyboard.instantiateViewControllerWithIdentifier("SNPMTCH.chat") as! UIViewController
chatViewController.title = "Chat"
chatViewController.view.backgroundColor = gray

var img1 = UIImage(named: "profile")
img1 = img1?.imageWithRenderingMode(.AlwaysTemplate)
var img2 = UIImage(named: "gear")
img2 = img2?.imageWithRenderingMode(.AlwaysTemplate)
var img3 = UIImage(named: "chat")
img3 = img3?.imageWithRenderingMode(.AlwaysTemplate)

var items = [UIImageView(image: img1), UIImageView(image: img2), UIImageView(image: img3)]
var controllers = [profileTableViewController!, homeViewController, chatViewController]
controller = SLPagingViewSwift(items: items, controllers: controllers, showPageControl: false)

controller?.pagingViewMoving = ({ subviews in
  for v in subviews {
    var lbl = v as! UIImageView
    var c = gray

    if(lbl.frame.origin.x > 45 && lbl.frame.origin.x < 145) {
      c = self.gradient(Double(lbl.frame.origin.x), topX: Double(46), bottomX: Double(144), initC: orange, goal: gray)
    }
    else if (lbl.frame.origin.x > 145 && lbl.frame.origin.x < 245) {
      c = self.gradient(Double(lbl.frame.origin.x), topX: Double(146), bottomX: Double(244), initC: gray, goal: orange)
    }
    else if(lbl.frame.origin.x == 145){
      c = orange
    }
    lbl.tintColor = c
  }
})

controller?.navigationSideItemsStyle = .SLNavigationSideItemsStyleNormal

controller?.setCurrentIndex(1, animated: false)

self.nav = UINavigationController(rootViewController: controller!)
self.window?.rootViewController = self.nav
self.window?.backgroundColor = UIColor.whiteColor()
self.window?.makeKeyAndVisible()

return true

}