calimarkus / JDFlipNumberView

[iOS] Animated analog flip numbers like airport/train-station displays (Swift/SwiftUI ready)
MIT License
785 stars 138 forks source link

imageSnapshotAfterScreenUpdates Problem when flipping different Views on different Screens #39

Open makadev opened 9 years ago

makadev commented 9 years ago

I'm using the JDFlipImageView flipToView Method to animate 2 Views concurrently. One on an iOS 8 Device and one on a connected Beamer (simply an UIWindow with UIView where an UIImageView is displayed and flipped, same constellation on the iOS Device). The animation is invoked first for the Beamer's View and then for the iOS Device View.

It's quite simple something like:

  ...
  if(self->secondScreen) {
    UIImageView* beamerLastImageView = self->newBeamerImageView;
    self->newBeamerImageView = [[UIImageView alloc]
initWithImage:self->beamerImage];
  }
  UIImageView* lastImageView = self->newImageView;
  self->newImageView = [[UIImageView alloc] initWithImage:self->newImage];
  ...
  if(self->secondScreen) {
    [beamerLastImageView flipToView:self->newBeamerImageView
duration:dur direction:dir completion:^(BOOL finished){ ... }];
  }
  [lastImageView flipToView:self->newImageView duration:dur
direction:dir completion:^(BOOL finished){ ... }];

The Problem is that shortly before the flip animation an Image appears on the iOS Device View, but not on the Beamer. It is half the Size (may be due to the Beamers windows frame being 1/2 of that of the Devices View) and rotated by 180 degree.

After few hours of reading my code (can't exactly debug the APP while using a connected display) which is quite short for the animations, I started reading through the code path invoked by flipToView and it seems that imageSnapshotAfterScreenUpdates either makes a wrong Image or somehow mixes things between the 2 screens.

For now I worked around it by exposing the addFlipViewWithAnimationFromImage and using my own Images directly from the UIImageViews. This works without Problems.

I couldn't find any Information as to why this Problem occurs.

calimarkus commented 9 years ago

For ImageViews you can also use JDFlipImageView and setImageAnimated:: https://github.com/jaydee3/JDFlipNumberView/blob/master/JDFlipNumberView/JDFlipImageView.h

makadev commented 9 years ago

Thank you for the Information.

I'll leave it up to you to close this issue or investigate it further.