iOS Question [SOLVED] Is this a bug in SetLayoutAnimated

JackKirk

Well-Known Member
Licensed User
Longtime User
I'm in the process of porting an app from B4A to B4I.

In B4A version I have a nice little splash screen that is in part driven by B4A.SetLayoutAnimated - which moves a graphic at a constant speed off the screen

I am finding that B4I.SetLayoutAnimated moves the graphic in a very non-constant speed off the screen (seems to asymptote to 0).

I have attached a little bit of test code which illustrates the point (keep an eye on stopwatch at top).

Is this a bug or a characteristic of the underlying iOS control?

Is there a way to correct it?

Thanks...
 

Attachments

  • Test.zip
    12.3 KB · Views: 249

Erel

B4X founder
Staff member
Licensed User
Longtime User
(It is a mistake to show it from Page_Resize event. This event can fire multiple times while your app is running.)

This is the default animation type in iOS. You can use this code to create a linear animation:
B4X:
Sub SetLayoutAnimatedLinear(View As View, Duration As Int, Dumping As Float, Left As Float, Top As Float, Width As Float, Height As Float)
   Dim no As NativeObject = Me
   no.RunMethod("SetLayoutAnimated::::::", Array(View, Duration, Left, Top, Width, Height))
End Sub

#if OBJC
-  (void)SetLayoutAnimated:(UIView*)v: (int)DurationMS :(float)Left :(float)Top :(float) Width :(float)Height {
  void (^setlayout)() =  ^{
  v.bounds = CGRectMake(0, 0, Width, Height);
  v.center = CGPointMake(Left + Width / 2, Top + Height / 2);
  };
  [UIView animateWithDuration:DurationMS / 1000.0 delay:0 options:UIViewAnimationOptionCurveLinear
  animations:setlayout completion:nil];
}
#End If
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
(It is a mistake to show it from Page_Resize event. This event can fire multiple times while your app is running.)
Erel, I understand this, it was a quick and dirty to show the issue.

Thanks for the fix, it worked perfectly...
 
Last edited:
Upvote 0
Top