2016-07-07 59 views
0

我已经建立了我的表格视图填充两个数组。当它只是在tableview中时,我成功地完成了这项工作,但不是我把它放在视图控制器中,没有显示任何信息。我不知道我做错了什么,我设置viewController就像我用tableviewcontroller。 应该发生的情况是,将创建一行并填入信息并继续执行,直到填写完所有数据。 问题是没有数据显示出来。我不知道我在这里错过了什么。任何帮助,将不胜感激。没有任何信息显示在我的tableview里面viewController

这是我的;

class MyViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 


var titleDate = ["Apple", "Apricot", "Banana", "Kiwi" , "Juniperberry" , "GhostBusteres"] 
var descriptionDate = ["One", "Two", "Three", "4", "5", "6"] 

@IBOutlet weak var myTableView: UITableView! 
// MARK: - UIViewController lifecycle 

override func viewDidLoad() { 
    super.viewDidLoad() 
    myTableView.editing = true 
} 

// MARK: - UITableViewDataSource 

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    return titleDate.count 
} 

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
    let cell = tableView.dequeueReusableCellWithIdentifier("Coupon", forIndexPath: indexPath) as! CouponTableViewCell 


    cell.couponTitle.text = titleDate[indexPath.row] 
    cell.couponDescription.text = descriptionDate[indexPath.row] 
    cell.couponAnother.text = "Like a bloody storm" 

    return cell 
} 

func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle { 
    return .None 
} 

func tableView(tableView: UITableView, shouldIndentWhileEditingRowAtIndexPath indexPath: NSIndexPath) -> Bool { 
    return false 
} 

func tableView(tableView: UITableView, moveRowAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath) { 
    let movedObject = self.titleDate[sourceIndexPath.row] 
    titleDate.removeAtIndex(sourceIndexPath.row) 
    titleDate.insert(movedObject, atIndex: destinationIndexPath.row) 
    descriptionDate.removeAtIndex(sourceIndexPath.row) 
    descriptionDate.insert(movedObject, atIndex: destinationIndexPath.row) 
    NSLog("%@", "\(sourceIndexPath.row) => \(destinationIndexPath.row) \(titleDate)") 
    // To check for correctness enable: self.tableView.reloadData() 

} 

}

而且我也有一个标签链接到变量和也适用细胞类。

谢谢你的帮助。

+0

你需要设置故事板的代表和数据源 –

回答

相关问题