ここでは私のカスタムセルクラスからのコードです:ここではカスタムTableViewCellスウィフト
import UIKit
class CustomOrderTableViewCell: UITableViewCell {
@IBOutlet var MealName: UILabel!
@IBOutlet var MealPrice: UILabel!
@IBOutlet var MealDescription: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
@IBAction func deleteMeal(sender: AnyObject) {
}
}
は、テーブルビュー関連の機能です:
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return mealArray.orderedMeals.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
print("in")
var cell = tableView.dequeueReusableCellWithIdentifier("orderCell", forIndexPath: indexPath) as! CustomOrderTableViewCell
cell.MealName.text = mealArray.orderedMeals[indexPath.row].mealName
cell.MealDescription.text = mealArray.orderedMeals[indexPath.row].mealDescription
let price = NSString(format: "%.2f", mealArray.orderedMeals[indexPath.row].mealPrice) as String
cell.MealPrice.text = "R" + price
return cell
}
問題が何もテーブルビューに表示されないされることをで、 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
は呼び出されません。 すべてのソリューション?ありがとう
チェックhttp://stackoverflow.com/questions/25541786/custom-uitableviewcell-from-nib-in-swiftまたはhttp://shrikar.com/uitableview-and-uitableviewcell-customization-in-swift/ – jose920405