2015-01-05 6 views
0

기본 tableview 셀을 사용하여 create tableview를 시도합니다. 각 셀에는 imageView와 title이 있습니다. 이미지가 서버에서 비동기 적으로로드되었습니다. 이 목적을 위해 Alamofire 프레임 워크를 사용합니다.신속한 선택 후 UITableViewCell 잘못된 레이아웃

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
     let CellID: NSString = "Cell" 
     let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: CellID) 

     cell.textLabel!.text = "test #\(indexPath.row)" 
     var imageURL = repArray[indexPath.row]["image"]!! 

     cell.imageView!.image = UIImage(named: "recept") 

     Alamofire.request(.GET, imageURL).response() { 
      (_, _, data, _) in 

      let image = UIImage(data: data! as NSData) 
      dispatch_async(dispatch_get_main_queue(), { 
       if let cellToUpdate = tableView.cellForRowAtIndexPath(indexPath) { 
        cellToUpdate.imageView!.image = image 
       } 
      }) 

     } 

     return cell 
    } 

그러나 임의의 tableview 셀을 선택하면 이미지 뷰의 크기가 변경됩니다.

Before selection After selection

가 발생하는 이유는 무엇입니까?

답변

0

tableView:didSelectRowAtIndexPath 또는 tableView:willSelectRowAtIndexPath 방법이 있습니까? 그렇게한다면, 어떻게 생겼는지 보여줄 수 있습니까? 셀의 레이아웃을 변경하는 부분 인 것처럼 보입니다.

+0

아니요, 아닙니다. –

+0

문제가 해결 되었습니까? 나는 똑같은 문제를 치고있다. – user3204765

관련 문제