You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use your framework to be able to get an index list for my collection view.
Before actually doing this inside of my project I figured it would be useful to make a test project to test the working and functionality of it first.
this is my entire controller. I'm using swift 3
do you have any idea why it might not be working? is there something I'm doing wrong?
Basically indexViewValueChanged is never called
import UIKit
import BDKCollectionIndexView
classViewController:UIViewController,UICollectionViewDataSource,UICollectionViewDelegate{@IBOutlet weak varcollectionView:UICollectionView!@IBOutlet weak varindexView:BDKCollectionIndexView!letreuseIdentifier="cell" // also enter this string as the cell identifier in the storyboard
varitems=["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48"]overridefunc viewDidLoad(){
super.viewDidLoad()letindexWidth:CGFloat=28letframe=CGRect(x:(collectionView.frame.size.width - indexWidth),
y: collectionView.frame.size.height,
width: indexWidth,
height: collectionView.frame.size.height)letindexView=BDKCollectionIndexView.init(frame: frame, indexTitles:nil)
indexView?.autoresizingMask =[.flexibleHeight,.flexibleLeftMargin]
indexView?.addTarget(self, action:Selector("indexViewValueChanged:"), for:.valueChanged)
view.addSubview(indexView!)self.indexView.indexTitles = items
}overridefunc didReceiveMemoryWarning(){
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}func collectionView(_ collectionView:UICollectionView, numberOfItemsInSection section:Int)->Int{returnself.items.count
}
// make a cell for each cell index path
func collectionView(_ collectionView:UICollectionView, cellForItemAt indexPath:IndexPath)->UICollectionViewCell{
// get a reference to our storyboard cell
letcell= collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath asIndexPath)as!MyCollectionViewCell
// Use the outlet in our custom class to get a reference to the UILabel in the cell
cell.myLabel.text =self.items[indexPath.item]
cell.backgroundColor =UIColor.cyan // make cell more visible in our example project
return cell
}
// MARK: - UICollectionViewDelegate protocol
func collectionView(_ collectionView:UICollectionView, didSelectItemAt indexPath:IndexPath){
// handle tap events
print("You selected cell #\(indexPath.item)!")}func indexViewValueChanged(){letpath="hello"print(path)}func indexViewValueChanged(sender:BDKCollectionIndexView){letpath=IndexPath(item:0, section:Int(sender.currentIndex))
collectionView.scrollToItem(at: path, at:.top, animated:false)
// If you're using a collection view, bump the y-offset by a certain number of points
// because it won't otherwise account for any section headers you may have.
collectionView.contentOffset =CGPoint(x: collectionView.contentOffset.x,
y: collectionView.contentOffset.y -45.0)}}
The text was updated successfully, but these errors were encountered:
Yeah, like @athulsai said — I think you'll need to update your syntax to the new Swift 3 #selector format, and it's likely (?) you'll need to mark your action method to be @objc.
I'm trying to use your framework to be able to get an index list for my collection view.
Before actually doing this inside of my project I figured it would be useful to make a test project to test the working and functionality of it first.
this is my entire controller. I'm using swift 3
do you have any idea why it might not be working? is there something I'm doing wrong?
Basically
indexViewValueChanged
is never calledThe text was updated successfully, but these errors were encountered: