2017-10-01 2 views
0

마스터 테이블보기에서 꽃의 이미지를 보여주는 마스터 디테일 앱이 있습니다. 자세히보기에서 더 큰 이미지를 보여주고 싶지만 마지막 이미지를 계속 보여줍니다.클릭 한 이미지 대신 마지막으로 이미지가 표시됩니다.

DetailViewController는 MasterViewController의 이미지를 마지막 이미지로 표시하고 있습니다.

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

: 아무리 MasterViewController에 클릭되는 내용, 세부 사항 보여주는 이미지가 마스터에서 목록의 마지막 이미지 .. MasterViewController.swift 파일에서

override func viewDidLoad() { 
    super.viewDidLoad() 

    imageView1.image = MasterViewController.MyVariables.flowerImage!.first 

가 없습니다, 여기에 코드입니다 나는이 함수에 일종의 디버깅했다. 그러나 오류 메시지 치명적인 오류가 표시됩니다.이 코드 줄에서 선택적 값을 래핑하지 않고 예기치 않게 nil을 발견했습니다.

관련 문제