我的问题是关于这个问题的后续问题: Separating Data Source to another class in Swift 这个问题的人使用了我需要的东西!只有我在不同的环境中尝试它并且无法使其正常工作。
情况解释:
我有4个视图的屏幕构建:
所有主要控件都位于第一个(背景)视图控制器中,这里也是一个打开相机应用程序的按钮
我的代码中出现的错误如下:
tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7ff13b039a70
崩溃应用程序的那个:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7ff13b039a70'
我不知道如何解决这个问题,或者这是否可行 代码看起来像这样,我使用Datascouce类形成上一篇文章(重要的部分就像这样)
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!
我加载数据源的地方:
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
}
我打开相机应用程序的地方:
@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)
}
}