【发布时间】:2016-06-22 10:20:21
【问题描述】:
单击单元格时会出现一个弹出框。在这个弹出窗口中,有一个带有一行的 TableView。当我单击该行时,会出现三个带有动画的新行。我想删除那个动画。有可能吗?
这是我的代码:
extension PlanningActionTableViewController
{
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return numberOfRows()
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier("ActionCell", forIndexPath: indexPath) as!PlanningActionCell
// Info cells
if registration == nil
{
if slot.registrations.count > indexPath.row
{
let contact = slot.registrations[indexPath.row].contact
let name = contact.lastname + " " + contact.firstname
cell.actionLabel.text = (name.characters.count > 1 ? name : "Réservation en cours")
cell.accessoryType = .DisclosureIndicator
cell.imageSymbol.image = UIImage(named: "picto.user.default")
return cell
}
cell.actionLabel.text = "Ajouter"
cell.accessoryType = .None
cell.imageSymbol.image = UIImage(named: "picto.user.add")
return cell
}
// Actions cell
switch indexPath.row
{
case 0:
cell.actionLabel.text = "Détails"
cell.accessoryType = .None
cell.imageSymbol.image = UIImage(named: "picto.user.details")
case 1:
var state = "Non"
if let contact = registration?.contact
{
state = (contact.isArrived ? "Oui" : "Non")
}
cell.actionLabel.text = "Est arrivé: " + state
cell.accessoryType = .None
cell.imageSymbol.image = UIImage(named: "picto.user.valid")
default:
cell.actionLabel.text = "Supprimer booking"
cell.actionLabel.textColor = UIColor.redColor()
cell.imageSymbol.image = UIImage(named: "picto.user.delete")
cell.accessoryType = .None
}
return cell
}
}
行数:
func numberOfRows() -> Int
{
if registration == nil
{
return slot.subslotsCount
}
return 3
}
视频示例:
<iframe src="//gifs.com/embed/1wvE6R" frameborder="0" scrolling="no" width='480' height='220.7665505226481' style="-webkit-backface-visibility: hidden;-webkit-transform: scale(1);" ></iframe>
【问题讨论】:
-
首先,您的意思是什么动画,扩展弹出框或新行的外观,或两者兼而有之?其次,
cellForRowAtIndexPath方法本身不负责行动画,在扩展数据源的地方添加代码,即插入新行和/或更改numberOfRows的值。 -
是新行的外观。当我显示三行(或更多)时,弹出框的动画会向下增加。
-
如果您不想要动画,请计算您想要的弹出框的内容大小,手动设置并触发不带动画的数据源更新。
-
没有别的办法了吗?我在视频中举了一个例子。奇怪的是,没有一个选项可以在没有动画的情况下执行它,或者只是通过更改动画来执行它?
-
我觉得加上动画效果还不错。
标签: ios swift uitableview animation uipopovercontroller