当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - Xcode Swift: Static cells expanding not working

问题描述:

So I have a static grouped TableViewController In my first section I have 6 cells. 2 of the cells have UIPickerViews. I have been trying to get it a similar effect that Apple has gotten with there add Calendar events. When I click the Text Box the cell under it becomes visible, then when I click another text box it hides.

Here is the picture of the TableViewController:

The shown UIPickerView corresponds with the Race text box. There will be a grand total of 4 cells that this needs to be done to.

Here is the code that I got from another post:

 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

let myCell:UITableViewCell? = tableView.dequeueReusableCell(withIdentifier: "cellID",for: indexPath as IndexPath)

if(indexPath.row == 2){

myCell?.isHidden = true

}else{

myCell?.isHidden = false

}

return myCell!

}

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat

{

var rowHeight:CGFloat = 0.0

if(indexPath.row == 2)

{

rowHeight = 0.0

}

else

{

rowHeight = 216.0 //or whatever you like

}

return rowHeight

}

I have a TableViewController (CharacterTableViewController) that is used to open this TableViewController (CharacterInfoViewController).

Now I realize that I am missing something because nothing happens. I'm not sure where I need to from here...

分享给朋友:
您可能感兴趣的文章:
随机阅读: