亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

UITableView行動畫的持續時間和完成回調

UITableView行動畫的持續時間和完成回調

慕田峪9158850 2019-12-12 14:04:07
是否可以指定UITableView行動畫的持續時間,或者在動畫完成時獲取回調?我想做的是在動畫完成后閃爍滾動指示器。在此之前進行閃光燈不會執行任何操作。到目前為止,我要解決的問題是延遲半秒(這似乎是默認的動畫持續時間),即:[self.tableView insertRowsAtIndexPaths:newRows                      withRowAnimation:UITableViewRowAnimationFade];[self.tableView performSelector:@selector(flashScrollIndicators)                     withObject:nil                     afterDelay:0.5];
查看完整描述

3 回答

?
Cats萌萌

TA貢獻1805條經驗 獲得超9個贊

請注意,在iOS 7上,使用UIView Animation將CATransaction圍繞起來可以控制表格動畫的持續時間。


[UIView beginAnimations:@"myAnimationId" context:nil];


[UIView setAnimationDuration:10.0]; // Set duration here


[CATransaction begin];

[CATransaction setCompletionBlock:^{

? ? NSLog(@"Complete!");

}];


[myTable beginUpdates];

// my table changes

[myTable endUpdates];


[CATransaction commit];

[UIView commitAnimations];

UIView動畫的持續時間對iOS 6無效。也許在UIView級別,iOS 7表格動畫的實現方式有所不同。


查看完整回答
1 反對 回復 2019-12-12
?
動漫人物

TA貢獻1815條經驗 獲得超10個贊

如今,如果要執行此操作,則可以從iOS 11開始使用新功能:


- (void)performBatchUpdates:(void (^)(void))updates 

                 completion:(void (^)(BOOL finished))completion;

在更新閉包中,放置與beginUpdates()/ endUpdates部分相同的代碼。并且在所有動畫之后執行完成。


查看完整回答
反對 回復 2019-12-12
?
墨色風雨

TA貢獻1853條經驗 獲得超6個贊

剛遇到這個。方法如下:


目標C


[CATransaction begin];

[tableView beginUpdates];

[CATransaction setCompletionBlock: ^{

    // Code to be executed upon completion

}];

[tableView insertRowsAtIndexPaths: indexPaths

                 withRowAnimation: UITableViewRowAnimationAutomatic];

[tableView endUpdates];

[CATransaction commit];

迅速


CATransaction.begin()

tableView.beginUpdates()

CATransaction.setCompletionBlock {

    // Code to be executed upon completion

}

tableView.insertRowsAtIndexPaths(indexArray, withRowAnimation: .Top)

tableView.endUpdates()

CATransaction.commit()


查看完整回答
反對 回復 2019-12-12
  • 3 回答
  • 0 關注
  • 1045 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號