import UIKit
class ListView:
UIViewController,UITableViewDataSource,UITableViewDelegate {
var data = ["Settings ", "Power", "Background Image",
"My favorates","My collections","Music", "Videos", "Photos"]
var detailImages : Array<UIImage> = [
UIImage(named: "r1.png")!,
UIImage(named: "r2.png")!,
UIImage(named: "r4.png")!,
UIImage(named: "r5.png")!,
UIImage(named: "r6.png")!]
override func viewDidLoad() {
super.viewDidLoad()
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell",
forIndexPath: indexPath)
cell.textLabel?.text = data[indexPath.row]
//cell.textLabel?.text = "Next View"
// to show the alternate color in cells
if indexPath.row % 2 == 0 {
cell.backgroundColor = UIColor.greenColor()
} else
{
cell.backgroundColor = UIColor.whiteColor()
}
return cell
}
func tableView(tableView: UITableView,
didSelectRowAtIndexPath indexPath: NSIndexPath) {
let nextView = self.storyboard?.instantiateViewControllerWithIdentifier("InterestViewController")
as! InterestViewController
self.navigationController?.pushViewController(nextView,
animated: true)
}
答案 0 :(得分:1)
您可以声明属性
var detailImages = [UIImage]()
<{1>}中的,并使用InterestViewController
方法将您的图片分配给此媒体资源:
didSelectRowAtIndexPath