2016-04-15 11 views
0

ここでは私のカスタムセルクラスからのコードです:ここではカスタム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は呼び出されません。 すべてのソリューション?ありがとう

+0

チェックhttp://stackoverflow.com/questions/25541786/custom-uitableviewcell-from-nib-in-swiftまたはhttp://shrikar.com/uitableview-and-uitableviewcell-customization-in-swift/ – jose920405

答えて

1

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellが呼び出されない場合は、IBのUITableViewDataSourceを正しく接続していないことを意味します。 dataSourceプロパティをViewControllerに接続していることを確認してください。また、ViewController、TableView、およびCell自体にすべてのクラスが設定されていることをよく確認してください。

+0

いいえ私は問題を見つけた、私の配列は空だった –

関連する問題