0
뷰 뷰어에서 뷰 컨트롤러로 데이터를 가져 오려고합니다. 지금까지 셀에 표시되는 데이터를 이동할 수 있지만 어떤 이유로 변수를 가져갈 수 없습니다. 여기segue 동안 tableview 변수를 전달하십시오. IndexPath
이미
//Prepare for Segue
destination.titleSegue = (cell?.textLabel?.text!)!
destination.priceSegue = (cell?.detailTextLabel?.text!)!
destination.imageSegue = (cell?.imageView?.image!)!
노력하고 모든 데이터가 두 번째보기를 통해 전송됩니다 것입니다.
지금, 나는 당신에게 보여줍니다 내 cellForRowAtIndexPath
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .Subtitle , reuseIdentifier: cellId)
cell.backgroundColor = UIColor.clearColor() //Makes colour of cells clear so we can see the background
cell.textLabel?.text = userList[indexPath.row].title //Shoes Name
cell.textLabel?.textColor = UIColor.whiteColor() //Sets text colour to white
cell.detailTextLabel?.text = "$\(userList[indexPath.row].price!)" //Displays price of shoes
cell.detailTextLabel?.textColor = UIColor.whiteColor() //Sets text colour to white
//LOOK HERE STACK OVERFLOW*******
let descriptionText = userList[indexPath.row].description
let URLString = self.userList[indexPath.row].listingImageURL //Finds URL of profile image
let URL = NSURL(string:URLString!)! //Converts URL Stirng to NSURL
cell.imageView?.frame = CGRectMake(10,10,100,100) //Sets frame size for images on tableview TODO
cell.imageView?.contentMode = .ScaleAspectFit //Sets image to aspect fill for image TODO
cell.imageView?.hnk_setImageFromURL(URL) //Displays image on table view from Haneke Framework
return cell
}
당신은 내가 데이터까지 이동 얻기 위해 CellForRowAtIndexPath
에서 "descriptionText"변수를 구문 분석 호출 할 필요가 무엇을 내 prepare for segue
로 돌아갈 경우 두 번째보기 컨트롤러? @vadian 말했듯이
같이있는 tableView 선택한 행의 indexPath에 액세스 할 수 있습니다? –
항상 그렇듯이 ** 뷰 (셀)에서 데이터를 가져 오지 않고 모델 ('userList')에서 가져옵니다. segue를 수행하는 방법 (직접 또는'didSelect ... '을 통해)에 따라'sender' 매개 변수의 셀이나'tableView.indexPathForSelectedRow'를 통해'prepareForSegue'에서 색인 경로를 얻어야합니다. – vadian