我正在研究的项目取决于UITableView
。我在UIStoryboard
内建了六个主要类别。我希望每个单元格与另一个UITableView
相关联。
我使用segue代理,但它不起作用。我需要一个方法来委托UITableView
文件:
class CategoriesView: UITableViewController {
@IBOutlet weak var OthersCell: UITableViewCell!
@IBOutlet weak var StoreCell: UITableViewCell!
@IBOutlet weak var ArtAndDesigneCell: UITableViewCell!
@IBOutlet weak var StudentServicesCell: UITableViewCell!
@IBOutlet weak var BeautyCell: UITableViewCell!
@IBOutlet weak var CheefsCell: UITableViewCell!
override func viewDidLoad() {
super.viewDidLoad()
func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier=="CheefsCelll") {let _=segue.destinationViewController as! CheefsView}
else if (segue.identifier=="BeautyCell") {let _=segue.destinationViewController as! BeautyView}
else if (segue.identifier=="StudentServicesCell") {let _=segue.destinationViewController as! StudentServicesView}
else if (segue.identifier=="ArtAndDesigneCell") {let _=segue.destinationViewController as! ArtAndDesigneView}
else if (segue.identifier=="StoreCell") {let _=segue.destinationViewController as! StoreView}
else if (segue.identifier=="OthersCell") {let _=segue.destinationViewController as! OthersView}
}
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 0
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 6
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
cell.accessoryType=UITableViewCellAccessoryType.DisclosureIndicator
return cell
}
答案 0 :(得分:0)
首先,onLoad
方法UITableViewDataSource
必须返回一个不同于0的值。在您的情况下,它应该是1.
numberOfSectionsInTableView
如果这不起作用,请确保在IB或override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
中正确设置dataSource。