ios - How to hide collection view while table view view scrolling in swift -
i adjust while scrolling down table view, want hide collection view in swift, , when scroll open instagram. although found navigation bar , table view , couldn't find collection view , table view. here navigation bar , table view: https://www.natashatherobot.com/navigation-bar-interactions-ios8/. help. here simple code:
class viewcontroller: uiviewcontroller, uicollectionviewdelegateflowlayout, uicollectionviewdatasource,uitableviewdelegate, uitableviewdatasource { var collectionview: uicollectionview! var tableview: uitableview = uitableview() var items: [string] = ["viper", "x", "games","viper", "x", "games","viper", "x", "games","viper", "x", "games","viper", "x", "games", "x", "games","viper", "x", "games","viper", "x", "games","viper", "x", "games","viper", "x", "games", "x", "games","viper", "x", "games","viper", "x", "games","viper", "x", "games","viper", "x", "games"] override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. let layout: uicollectionviewflowlayout = uicollectionviewflowlayout() layout.sectioninset = uiedgeinsets(top: 20, left: 10, bottom: 10, right: 10) layout.itemsize = cgsize(width: 90, height: 120) let :cgrect = cgrect(x: 0, y: 0, width: self.view.frame.size.width, height: 130) collectionview = uicollectionview(frame: a, collectionviewlayout: layout) collectionview.datasource = self collectionview.delegate = self collectionview.registerclass(uicollectionviewcell.self, forcellwithreuseidentifier: "cell") collectionview.backgroundcolor = uicolor.whitecolor() self.view.addsubview(collectionview) tableview.frame = cgrectmake(0, 130 , self.view.frame.size.width , self.view.frame.size.height - 130); tableview.delegate = self tableview.datasource = self tableview.registerclass(uitableviewcell.self, forcellreuseidentifier: "cell") self.view.addsubview(tableview) } override func viewdidappear(animated: bool) { super.viewdidappear(animated) } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int { return 4 } func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell { let cell = collectionview.dequeuereusablecellwithreuseidentifier("cell", forindexpath: indexpath) cell.backgroundcolor = uicolor.orangecolor() return cell } func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { return self.items.count } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell:uitableviewcell = tableview.dequeuereusablecellwithidentifier("cell")! uitableviewcell cell.textlabel?.text = self.items[indexpath.row] return cell } func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { print("you selected cell #\(indexpath.row)!") }
}
Comments
Post a Comment