0

I have succesfully loaded these two default cells of tableview. But my problem is I have to animate these two cells.For example one custom cell will load first then after 1 minutes another cell will load.Now new loaded cell of tableview appear on the top.

I have use cell will display method for animation but nothing happened.How to do this type of animation with time duration.

akshay
  • 765
  • 6
  • 20
  • show your tried code – Anbu.Karthik Mar 01 '17 at 10:59
  • func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { previousIndexPath = indexPath Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(someSelector), userInfo: nil, repeats: false) } – akshay Mar 02 '17 at 06:12
  • func someSelector() { if previousIndexPath?.row == 0 { let identifier = "TableViewCell2" let cell = self.homeTableView.dequeueReusableCell(withIdentifier: identifier, for: previousIndexPath!) as UITableViewCell cell.alpha = 0.0 cell.isHidden = true UIView.animate(withDuration: 0.1, animations: { cell.alpha = 1.0 cell.isHidden = false }) } } – akshay Mar 02 '17 at 06:12

1 Answers1

0

There are a lot of libraries out there for animations like this , also you can try with core graphics animation which will be a little time consuming.

for waiting 1 minute use the timer

or

use UNIX function sleep

sleep(4)

or

Swift 3

With GCD:

let delayInSeconds = 4.0
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + delayInSeconds) {

    // here code perfomed with delay

}
Community
  • 1
  • 1
Guru Teja
  • 127
  • 2
  • 13