【发布时间】:2016-08-04 23:00:11
【问题描述】:
我在从 tableview 移动到视图时遇到问题。
为了解释这个问题,我有一个名为 myObjects 的视图,其中包含一个表视图,其中加载了一些用户对象,如果用户点击单元格,则使用模态 segue 调用一个新视图(objectConsult)。
在这个视图中,用户将找到关于他的对象的所有信息,当他点击与模态 segue 链接的后退按钮时,他会回到 myObjects。
我的问题是,每次我从 objectConsul 中点击后退按钮时,我的 tableview 都会重新加载单元格,我已经成功阻止了 Objective-C 中的重新加载,但很快我不明白我必须做什么才能解决问题.
override func viewDidAppear(animated: Bool) {
tableView.reloadData()
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell:CustomCell = self.tableView.dequeueReusableCellWithIdentifier("Cell") as! CustomCell
cell.picture.frame = CGRectMake(5,0,120,103)
cell.title.text = repos[indexPath.row].title
let i = settings.ImagesCachedArray.indexOf({$0 == repos[indexPath.row].idobjet!})
let myImageName = "\(settings.ImagesCachedArray[i!]).png"
let imagePath = fileInDocumentsDirectory(myImageName)
if let _ = self.loadImageFromPath(imagePath) {
cell.picture.image = self.loadImageFromPath(imagePath)
}
else {
let imgzeroresult = UIImage(contentsOfFile: NSBundle.mainBundle().pathForResource("noimage", ofType: "png")!)
cell.picture.image = imgzeroresult
}
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
performSegueWithIdentifier("mysegue", sender: self.view)
}
任何帮助将不胜感激。
【问题讨论】:
标签: swift tableview segue reload