我有一个Master-Detail应用程序,它显示Master表视图中的鲜花图像。我想在详细信息视图中显示更大的图像,但它会继续显示最后一个图像。
DetailViewController将MasterViewController中的图像显示为最后一个图像。无论在MasterViewController中点击什么,详细显示的图像是Master中列表中的最后一个图像..
override func viewDidLoad() {
super.viewDidLoad()
imageView1.image = MasterViewController.MyVariables.flowerImage!.first
在MasterViewController.swift文件中,这里是代码:
override public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell",
for: indexPath)
//cell.textLabel!.text = siteNames![indexPath.row]
switch (indexPath.section) {
case kRedSection:
do { cell.textLabel!.text = redFlowers[indexPath.row]
cell.detailTextLabel!.text = siteDetailRed![indexPath.row]
}
case kBlueSection:
do {
cell.textLabel!.text = blueFlowers[indexPath.row]
cell.detailTextLabel!.text = siteDetailBlue![indexPath.row]
}
default:
do {
cell.textLabel!.text = "Unknown"
cell.detailTextLabel!.text = "Unknown"
}
}
let test = UIImage(named: cell.textLabel!.text!)!
cell.imageView!.image = test
MyVariables.flowerImage = [test]
print("MyVariables.flowerImage", MyVariables.flowerImage)
return cell
}
答案 0 :(得分:0)
我有点调试它到这个功能。但是,它显示错误消息致命错误:在此行代码中解包可选值时意外地发现nil:
foreach(KeyValuePair<string,string> item in dict)
{
Console.WriteLine("Key = {0}, Value = {1}", item.Key, item.Value);
}
Console.ReadLine();