well my question is an follow up question on this question: Separating Data Source to another class in Swift The person of that question used what i need! only im trying it in a differnt setting and can't get it working properly.
The situation explained:
I have an screen build of 4 views:
- background and some text
- An big view container with a collection view
- An small view placed over the collection view(alpha bottom bar)
- An tabelview(dropdown animation controlled)
all the major controls are located in the first(background) view controller and here is also an button to open the camera app
The error that im getting in my code is the following:
tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7ff13b039a70
And the one that crashes the app:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7ff13b039a70'
I do not know how to fix this or if this is even posible The code looks like this and im using the Datascouce class form the previous post(the parts that matter like this)
class ViewControllerImagePicker: UIViewController, UIImagePickerControllerDelegate ,UINavigationControllerDelegate, UITableViewDelegate {
var user: User?
@IBOutlet var dropdownView: UITableView!
@IBOutlet var amountLabel: UILabel!
@IBOutlet weak var checkButtonOutlet: UIButton!
@IBOutlet weak var bottom_bar: UIView!
@IBOutlet weak var collectionView: UIView!
And the place where i load the datasource:
override func viewDidLoad() {
super.viewDidLoad()
var myColor : UIColor = UIColor( red: 0, green: 0, blue:0, alpha: 1.0 )
let screenSize: CGRect = UIScreen.mainScreen().bounds
bottom_bar.frame = CGRectMake(0
,screenSize.height - bottom_bar.frame.size.height
,bottom_bar.frame.size.width
,bottom_bar.frame.size.height);
collectionView.bringSubviewToFront(bottom_bar)
checkButtonOutlet.layer.cornerRadius = 24
checkButtonOutlet.layer.borderColor = myColor.CGColor
checkButtonOutlet.layer.borderWidth = 1
amountLabel.layer.cornerRadius = 15
amountLabel.layer.masksToBounds = true
var dataSource: TableDataSource = TableDataSource(items: ["One", "Two", "Three"], cellIdentifier: "Cell")
dropdownView.dataSource = dataSource
}
And the place where i open my camera app:
@IBAction func pictureCheck(sender: AnyObject) {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
println("Button capture")
var imag = UIImagePickerController()
imag.delegate = self
imag.sourceType = UIImagePickerControllerSourceType.Camera;
imag.mediaTypes = [kUTTypeImage]
imag.allowsEditing = false
self.presentViewController(imag, animated: true, completion: nil)
}
}