iOS Tutorial PageViewController

PageViewController is a pages controller (similar to NavigationController and TabBarController) that allows the user to switch pages with a swipe gesture. It is similar to B4A ViewPager.

Using PageViewController is simple. You initialize the controller with the list or array of pages.
The next step is to set it as the key controller:
B4X:
Private Sub Application_Start (Nav As NavigationController)
   Page1.Initialize("Page1")
   Page1.RootPanel.LoadLayout("Layout1")
   Page2.Initialize("Page2")
   Page2.RootPanel.LoadLayout("Layout2")
   Page3.Initialize("Page3")
   Page3.RootPanel.LoadLayout("Layout3")
   PVC.Initialize("pvc", Array(Page1, Page2, Page3))
   App.KeyController = PVC 
End Sub

Video example:


The example project is attached.

Note that there is no navigation bar. The title is made of a label.
 

Attachments

  • PageViewController.zip
    4.5 KB · Views: 1,619

little3399

Active Member
Licensed User
Longtime User
HI, I using hosted builder as flollowing message ...

upload_2016-2-21_23-30-2.png
:(
 

little3399

Active Member
Licensed User
Longtime User
Tks , I using the hosted builder to building the demo app , it running very well !

and I updated the MacBuilder and running very well same as the hosted builder !

Tks again !:)
 
Last edited:

pedrocam

Member
Licensed User
Longtime User
Hello fellow programmers,

I am using PVC and I am trying to open directly to page2 if a condition is met. However I do not know how to change the page with code for the PVC controller and and haven't been able to guess it or find any documentation. Any help? Thanks!

Pedro
 

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Guys

is there a way to reference current page?

In particular, I am using mail composer from inside a class (shared code with B4A). According to the sample code, I need to reference Parent Page

B4X:
mailc.Show(pg)

is there a simple way of finding the current page without having to rely on some global variable that I have to set every time a page is loaded

Thanks in advance
 

iCAB

Well-Known Member
Licensed User
Longtime User
Thanks Erel, i will check it. I was just wondering if this changes the program flow. Currently, the same code works for B4A & B4I
 

OlavRossland

Member
Licensed User
Longtime User
PageViewController is a pages controller (similar to NavigationController and TabBarController) that allows the user to switch pages with a swipe gesture. It is similar to B4A ViewPager.

Using PageViewController is simple. You initialize the controller with the list or array of pages.
The next step is to set it as the key controller:
B4X:
Private Sub Application_Start (Nav As NavigationController)
   Page1.Initialize("Page1")
   Page1.RootPanel.LoadLayout("Layout1")
   Page2.Initialize("Page2")
   Page2.RootPanel.LoadLayout("Layout2")
   Page3.Initialize("Page3")
   Page3.RootPanel.LoadLayout("Layout3")
   PVC.Initialize("pvc", Array(Page1, Page2, Page3))
   App.KeyController = PVC
End Sub

Video example:


The example project is attached.

Note that there is no navigation bar. The title is made of a label.
Geting these messages when I start Your example in B4i - but Im not able to figur out what do do with the last line...

Application_Start​
Application_Active​
Page 1 is visible​
Unbalanced calls to begin/end appearance transitions for <B4INavigationController: 0x11f815200>.

I have not made any changes from the original example...
 

OlavRossland

Member
Licensed User
Longtime User
You can probably ignore it. Do you see any problem?
In IOS You can drag & drop text from one app to another (also on a iPhone- without split screen).

I’m now testing to drag & drop text from one page with webview to another page with textview, by scrolling over from webview-page to textview-page.

But…
I can drag & drop with PageViewController-method, but the +sign disappears when I drag the text over to the textview-page, and no text is paced when I drop the text in the textviewer.

But…
If I do the same test - in a new app without PageViewController-method, I can drag & drop the text by “scrolling” back to the textview-page by using the “page back button”. By this method the +sign stays, and after dropping the text in the textviewer, the textview is updated with the new text.
 
Top