小编Mas*_*owe的帖子

tableView节标题消失SWIFT

我有一个tableView设置,以便在触摸单元格时,它会在高度上展开以显示更多信息.tableView有5个部分.

我有一个错误:当一个单元格扩展时,该单元格下面的所有headersCells都不可见.控制台输出以下内容:"[31233:564745]没有重用表格单元格的索引路径"

在我的故事板中,我有2个自定义单元格:"myCell"用于数据承载单元格,"headerCell"用于标题.

func tableView(tableView:UITableView,didSelectRowAtIndexPath indexPath:NSIndexPath){

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

   let thisGoal : GoalModel = goalArray[indexPath.section][indexPath.row]


    if self.currentPath != nil && self.currentPath == indexPath  {
        self.currentPath = nil
    } else {
        self.currentPath = indexPath
    }
    tableView.beginUpdates()
    tableView.endUpdates()
}
Run Code Online (Sandbox Code Playgroud)

如果我在开始/结束更新之间输入tableView.reloadData(),它会正常运行,尽管标题背景变黑,并且失去动画.

我有所有标题声明的东西:func tableView(tableView:UITableView,viewForHeaderInSection section:Int) - > UIView?

我错过了什么?我真的很喜欢tableView仍然有动画,并保持背景clearColor().

提前致谢.我确实读过目标C答案,但无法让他们为我工作.我非常感谢SWIFT的一些帮助.

我认为问题是表单元格被重用的无索引路径.

header uitableview nsindexpath ios swift

36
推荐指数
4
解决办法
2万
查看次数

将我的UIImageView转换为SWIFT中的PFFile

我的故事板中有一个UIImageView,用户可以从手机中成功选择一个图像放置在ImageView中; 但是,我不知道如何从故事板到Parse.com.

任何代码将非常感激.有很多关于下载的教程,但最初没有保存.

uiimageview parse-platform swift pffile

1
推荐指数
1
解决办法
986
查看次数

访问tableView SWIFT中的文本字段

我有一个tableView.当点击/选择单元格时,单元格向下展开以显示多个资产.一个资产是文本字段.另一个是"提交"按钮.

当按下Submit按钮时,我需要从文本字段访问用户输入.我怎样才能做到这一点?

重要提示:由于已经选择/扩展了单元格,因此无法使用didSelectRowAtIndexpath.

目前我在customCell上有以下内容:

@IBAction func submitButtonPressed(sender: UIButton) {
    // prepareForSegue is on mainVC
    self.textString = self.textField.text
    println(self.textString) 
 }
Run Code Online (Sandbox Code Playgroud)

在MainVC的"prepareForSegue"中,我有以下内容:

       var cell : CustomCell = self.tableView.dequeueReusableCellWithIdentifier("myCell") as! CustomCell

        let path = self.tableView.indexPathForSelectedRow()!
            println(cell.textField.text)
            self.newText = cell.textString
            self.newInt = self.newText.toInt()

            println(self.newText)
            println(self.newInt)
Run Code Online (Sandbox Code Playgroud)

以下代码正确prints(self.textString) 然而 cell.textString,self.newText并且self.newInt始终如此nil.

知道为什么吗?

tableview custom-cell nsindexpath segue swift

1
推荐指数
1
解决办法
4760
查看次数