作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试为 TableView 单元格中的一系列图标图像设置动画,但无法让 ImageView.StartAnimating 工作。 TableView 位于 UITableViewController 中,并且有一个 TableViewDataSource 文件,其中设置了 TableView 内容。
在我的 TableViewDataSource 中,我设置了 PNG 数组并配置了各种动画首选项。
UIImage image0 = GetImage("Images/image_at_0_degrees@2x.png");
UIImage image45 = GetImage("Images/image_at_45_degrees@2x.png");
UIImage image90 = GetImage("Images/image_at_90_degrees@2x.png");
UIImage image135 = GetImage("Images/image_at_135_degrees@2x.png");
UIImage[] images = new UIImage[] { image0, image135, image90, image45 };
cell.ImageView.AnimationImages = images;
cell.ImageView.AnimationDuration = 0.5;
cell.ImageView.AnimationRepeatCount = 0;
cell.ImageView.Image = image0;
// cell.ImageView.StartAnimating(); // If called here images will animate
UITableViewCell cell = TableView.CellAt(NSIndexPath.FromRowSection(0, 2));
imagetoAnimate = (UIImageView)cell.ContentView.ViewWithTag(ICON_TAG);
private void Application_Event()
{
Console.WriteLine("Running on Thread ID {0}. Is Main thread? {1}", Thread.CurrentThread.ManagedThreadId, NSThread.IsMain); // Returns false
InvokeOnMainThread(delegate
{
Console.WriteLine("Running on Thread ID {0}. Is Main thread? {1}", Thread.CurrentThread.ManagedThreadId, NSThread.IsMain); // Returns true
imageToAnimate.StartAnimating(); // If called here images don't animate
UpdateCount();
UpdateStatus();
});
}
UIImage image0 = GetImage("Images/image_at_0_degrees@2x.png");
UIImage image45 = GetImage("Images/image_at_45_degrees@2x.png");
UIImage image90 = GetImage("Images/image_at_90_degrees@2x.png");
UIImage image135 = GetImage("Images/image_at_135_degrees@2x.png");
UIImage[] images = new UIImage[] { image0, image135, image90, image45 };
cell.ImageView.AnimationImages = images;
cell.ImageView.AnimationDuration = 0.5;
cell.ImageView.AnimationRepeatCount = 0;
cell.ImageView.Image = image0;
最佳答案
调用UITableView.ReloadData
将重新加载所有单元格,GetCell
将在您的表格 View 源上再次被调用。
这可能会阻止动画的发生。
关于ios - 为什么 ImageView.StartAnimating 不会在主线程上设置动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15641064/
有人可以向我澄清主线 DHT 规范中的声明吗? Upon inserting the first node into its routing table and when starting up th
我正在尝试使用 USB 小工具驱动程序使嵌入式设备作为 MTP 设备工作。 我知道 Android 从大容量存储设备切换到 MTP 设备已经有一段时间了,并且找到了 source code for M
我是一名优秀的程序员,十分优秀!