iOS Question ShowPage2 with different Transition?

ilan

Expert
Licensed User
hi

i would like to use showpage2 to show a page with an animation, but not the default animation of scrolling from right to left. i would like to use a different transition.

from apple doc i understand that we can only set the transition for a page when we initialize it and not after that because the "TransitionStyle" property is read only and needs to be set on initialization. like:

B4X:
init(transitionStyle: UIPageViewControllerTransitionStyle, navigationOrientation: UIPageViewControllerNavigationOrientation, options: [String : Any]? = nil)

how can we do it with b4i?

i know i could show the page as modal view controller but if i do it the page stays active and i cannot just show it again. i have to dismiss it but this needs to have always a list of the page stack and i dont want it. i just want to show a page with a specific transition and show another page from it and jump back from page 3 to page 1 and then again to page 2 and then to page 1....

is this possible?
 

ilan

Expert
Licensed User
Upvote 0

ilan

Expert
Licensed User
There is no simple way. It will be simpler to use a different panel instead of a different page.

ok. and how can I do it with a panel?

thank you
 
Upvote 0

ilan

Expert
Licensed User
actually it is working if I use this code:

https://www.b4x.com/android/forum/threads/page-over-tabbar.51019/#post-497775

B4X:
Sub PresentPage2(Parent As Page, dialog As Page)
  Dim no As NativeObject = dialog
  no.SetField("modalTransitionStyle",1)

  Dim no2 As NativeObject = Parent
  no2.RunMethod("presentModalViewController:animated:", Array(dialog, True))
End Sub

the problem is that if I want to show page 1 from page 3 I get an error that I tried to show an active page.
I can only go back with page dismiss.

would it be possible doing it like this and clear on each show page the navigation controller page stack?

never mind, i will use the modal dialog and go back with page dismiss.

thank you
 
Last edited:
Upvote 0

narek adonts

Well-Known Member
Licensed User
Horizontal flip.

B4X:
Sub ShowPageWithTransition(NavigationControl As NavigationController,PageToShow As Page,TransitionType As String, FromDirection As String)
    Dim no As NativeObject=Me
    no.RunMethod("trans:::",Array(NavControl,TransitionType,FromDirection))
    NavigationControl.ShowPage2(PageToShow,False)
End Sub

#if OBJC

-(void) trans: (UINavigationController*)nav :(NSString*)tp :(NSString*)from
{
CATransition *transition = [CATransition animation];
transition.duration = 0.3f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = tp;
transition.subtype = from;
[nav.view.layer addAnimation:transition forKey:nil];
}

#End If

and then

B4X:
ShowPageWithTransition(NavControl,page2,"flip","fromTop")

You can google for other types of transitions names

narek
 
Upvote 0

ilan

Expert
Licensed User
hi again, i have another question please.

is it posible to add that transition also to views and not only to a viewcontroller?

thank you
 
Upvote 0

narek adonts

Well-Known Member
Licensed User
hi again, i have another question please.

is it posible to add that transition also to views and not only to a viewcontroller?

thank you
Sure

B4X:
#IF OBJC

-(void) trans: (UIView*)nav :(NSString*)tp :(NSString*)from
{
CATransition *transition = [CATransition animation];
transition.duration = 0.3f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = tp;
transition.subtype = from;
NSLog(kCAMediaTimingFunctionEaseInEaseOut);
[nav.layer addAnimation:transition forKey:nil];
}

END IF

and then

B4X:
Sub ViewTransition(View As View,TransitionType As String, FromDirection As String)
    Dim no As NativeObject=Me
no.RunMethod("trans:::",Array(View,TransitionType,FromDirection))
End Sub
 
Upvote 0
Top