【发布时间】:2014-06-18 22:29:25
【问题描述】:
在 Objective-C 中,我的动画位看起来像这样:
[UIView animateWithDuration:0.5 animations:^{
[[[_storedCells lastObject] topLayerView] setFrame:CGRectMake(0, 0, swipeableCell.bounds.size.width, swipeableCell.bounds.size.height)];
} completion:^(BOOL finished) {
[_storedCells removeLastObject];
}];
如果我把它翻译成 Swift,它应该看起来像这样:
UIView.animateWithDuration(0.5, animations: {
self.storedCells[1].topLayerView.frame = CGRectMake(0, 0, cell.bounds.size.width, cell.bounds.size.height)
}, completion: { (finished: Bool) in
//self.storedCells.removeAtIndex(1)
})
它在注释掉的行上抱怨。我收到的错误是:Could not find an overload for 'animateWithDuration' that accepts the supplied arguments
我知道完成闭包接受一个布尔值并返回一个 void,但我应该能够在那里写一些与布尔无关的东西......对吗?
感谢任何帮助。
编辑:这是我在函数中声明我正在使用的数组的方式:
var storedCells = SwipeableCell[]()
一个接受 SwipeableCell 对象的数组。
【问题讨论】:
-
能否展示
self.storedCells的声明和赋值。 -
@0x7fffffff 我更新了答案
标签: closures swift ios8 animatewithduration