[英]Custom cell animation not working in didSelectRowAtIndexPath:
因此,我建立了一個自定義動畫,使該單元格離開屏幕離開左側(類似於deleteRowsAtIndexPaths:帶有UITableViewRowAnimationLeft的外觀)。 我這樣做是因為,如果我嘗試使用經典方法(帶有UITableViewRowAnimationLeft的deleteRowsAtIndexPaths :)批量刪除(刪除表中的所有行),則看起來不正確。 現在,我的自定義動畫看起來很棒,效果很好。 我有不同的菜單按鈕,這些按鈕首先使用動畫清除表,效果很好。 問題是,當我在表格中選擇一個單元格時,我希望啟動相同的動畫,但是由於某種原因,它根本不起作用(沒有動畫啟動)。 這是動畫代碼,應該是多余的(每個單元格都從最后一行到第一行調用此代碼):
NSIndexPath *ip = [NSIndexPath indexPathForRow:i inSection:0];
UITableViewCell *cell = [_table cellForRowAtIndexPath:ip];
CGRect newFrame;
if(i%2==0){
newFrame = cell.frame;
newFrame.origin.x = -[UIScreen mainScreen].bounds.size.width;
}else{
newFrame = cell.frame;
newFrame.origin.x = [UIScreen mainScreen].bounds.size.width;
}
[UIView animateWithDuration:0.2 delay:0 options:0
animations:^{cell.frame = newFrame;}
completion: ^(BOOL finished){
//[cell removeStatus];
if(i == 0){
[dataSource removeAllObjects];
[_table reloadData];
}
}];
我找到了解決此問題的方法。 我將動畫切換為基本動畫,現在可以使用了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.