[英]JSON data is returning empty cell in detailViewController?
I've a collectionViewCell (dynamic) with images and labels (loading from JSON
) inside a tableview. 我有一个collectionViewCell (动态),在表格视图中包含图像和标签 (从
JSON
加载)。 what i want is if i click on any Cell (contains image/folders) it should display detailedViewController with its content(also from JSON
). 我想要的是如果我单击任何单元格(包含图像/文件夹),它应该显示带有其内容(也来自
JSON
)的detailedViewController 。 my mainViewController works fine. 我的mainViewController工作正常。 displays the DATA.
显示数据。
inside mainViewController i used didSelectItemAtIndexPath like this 在mainViewController内部,我使用didSelectItemAtIndexPath这样
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
println("USER TAPPED item# \(indexPath.item)")
let subFolderView:SubFolderViewController = self.storyboard?.instantiateViewControllerWithIdentifier("subFolder") as! SubFolderViewController
self.navigationController?.pushViewController(subFolderView, animated: true)
subFolderView.imageSelected = self.Data[indexPath.row].AbsolutePath
subFolderView.imageSelected = self.Data[indexPath.row].Name
subFolderView.imageSelected = self.Data[indexPath.row].Description
BUT it is returning empty view when clicked. 但单击时返回空白视图。
in my secondViewController i have 在我的secondViewController中
var imageSelected:String!
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
var cell:SubFolderCollectionViewCell? = collectionView.dequeueReusableCellWithReuseIdentifier("CollectionViewCell", forIndexPath: indexPath) as? SubFolderCollectionViewCell
cell?.subFolderDescription.text = self.Data[indexPath.row].Description
cell?.subFolderName.text = self.Data[indexPath.row].Name
let picUrl = self.Data[indexPath.row].AbsolutePath
let url = NSURL(string: picUrl)
if(url != nil) {
let data = NSData(contentsOfURL : url!)
if(data != nil) {
cell?.subImage?.image = UIImage(data: data!)
}
}
return cell!
}
Please any one guide me to proceed further......i am new to iOS development and prefer swift!!!!!!! 请任何人指导我继续前进……我是iOS开发的新手,更喜欢swift !!!!!!!
IN my storyBoadrd both viewControllers contains 在我的storyBoadrd中,两个viewControllers都包含
View ,
查看 ,
Tableview ,
检视表
TableViewCell ,
TableViewCell ,
ContentView ,
ContentView ,
collectionView ,
collectionView ,
collectionViewCell .
collectionViewCell 。
inside that imageView and labels to display the data
在该imageView和标签内以显示数据
Any help is appreciated, Please let me know if u need more code............ 感谢您的任何帮助,如果您需要更多代码,请告诉我.........
Check your code.. 检查您的代码。
you use didDeselectItemAtIndexPath instead of didSelectItemAtIndexPath method.. 您使用didDeselectItemAtIndexPath而不是didSelectItemAtIndexPath方法。
It's different tableview delegate method. 这是不同的tableview委托方法。 change this and let me know if there is any issue.
改变这个,让我知道是否有任何问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.