iOS Question Pages fail to load on Ipad

Arf

Well-Known Member
Licensed User
Longtime User
All is running great on my iphone now (using b4i bridge) , but when I run on an iPad, whenever screens change to load a new page, I get a black screen. If I step through in debug, the screens load.

Any idea what this could be? The iPad seems to have ios 7.0 installed - it's a borrowed one so I can't update it until I get the appleID of the owner. Could this be the problem?
 

Arf

Well-Known Member
Licensed User
Longtime User
Log message:
Unbalanced calls to begin/end appearance transitions for Page (vc): .
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
According to the main page B4i works with any device running iOS 7+, so that shouldn't be the issue. Perhaps you can show us your Application_Start subs from Main and the other page?
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
I tried changing to ShowPage2(Page, False) but still have the same problem.

Generally what I am doing is, when I'm done with a page, this gets called
B4X:
Private Sub pg_Disappear
    pg.RootPanel.RemoveAllViews
End Sub
and then the on new page that next loaded:
B4X:
If pg.IsInitialized = False Then
        pg.Initialize("pg")
        pg.HideBackButton = True
    End If   
    pg.RootPanel.LoadLayout("sSettingsPage")
    Main.NavControl.ShowPage2(pg,False)

All my pages in the project are called 'pg' and are Private. I've set animation time to 0 and spring effect to 1 for all layouts in the designer, and only portrait is supported - I've don't have resize functions anywhere.
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
I do the same thing on all the pages pages in my app (around 12) - it seemed the simplest way to ensure each page starts with the same starting point each time, as the nature of my application means the user would go through all pages again and again, possibly dozens of times.

I could try what you suggest, but I don't quite understand - do you means simply moving all the code that is curently in code modules into class modules instead, and using the class to create a page and load the layout and then I can set the class instance to null to destroy it once I've done with that screen?

I suppose I could try, but it's all working beautifully on iPhone now and I really don't want to totally change the structure, rather just address whatever is causing the problem on iPad. Do you think it is the removing of views that is causing the problem?

thanks
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
**please bear with me, I'm gettig my head around some concepts here**

Ok so I've been studying Erel's ThreePages example. I had previously assumed that if I had a bunch of pages being called up in sequence, in order to return to a previous page I would need to do a "Main.NavControl.RemoveCurrentPage" in order for control to revert to the previous page, and do that for each page I wanted to go back through. Sometimes I would want to skip 6 pages back and not see any evidence of this on screen, hence calling "RemoveAllViews" before progressing onwards, so that I wouldn't see that page flick up when I returned to a previous page.

It looks to me now like I can call a sub on any page from any other page, which loads the layout of that page, and then control remains with that page as it's controls are then displayed on screen. Is this correct? So in fact if I want to return from pg6 to pg1, I don't need to to traverse backwards through all 6 pages, I can just call a function on pg1 that Loads the layout for page 1 and that's that? and I don't need to worrry about multiple instances of things being created if I never do any removing of views?

I think I overthunk that one a bit originally. Will experiment with the approach above tonight.
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Mmm, tried that but it makes the logical flow of the app way too complex, much simpler how I had it.
Is there any rule about when to use ResignFocus? Should I perhaps be doing that before either removing views or changes to a new page?
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
There is no good reason to remove all views and add them each time.
You can instead use a class for this page and create a new class instance each time if you want a clean page.

I just spent 2 hours converting all my pages from code modules to classes. If I declare a new instance of the class, the right layout gets loaded up, but I don't get any response to presses on screen items. I guess I misunderstood - did you mean use a class to create a non-global instance of Page1 alone, and leave all the UI stuff in a code module?
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Try to show the page with NavControl.ShowPage2(Page, False) 'without the animation.

I've just noticed that even using "ShowPage2(Page, False)", when the screens load the do come sliding in from the side rather than just apppear instantly. Is this expected?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've created a small example with a page implemented in a class module.
Each time a new class (and page) are created.

Note the usage of WeakRef to assure that the class instance is kept together with the page.

I've just noticed that even using "ShowPage2(Page, False)", when the screens load the do come sliding in from the side rather than just apppear instantly.
Make sure that the animation is set to 0 in the layout file.
 

Attachments

  • ColorPickerClass.zip
    2.9 KB · Views: 288
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Thanks Erel - much appreciated. I'll modify my class based project accordingly tonight.

Back to the problem with this ipad:
I've finally got it working, the problem had nothing to do with removing views, it was because I was using Main.NavControl.RemoveCurrentPage to close pages, when I should have been using Main.NavControl.RemoveCurrentPage2(False). It appears the "Unbalanced calls to begin/end appearance transitions for Page (vc):" means that I had unmatched Show Page and Remove Pages.

if using:
Main.NavControl.ShowPage2(pg,False)
I must use Main.NavControl.RemoveCurrentPage2(False) to unload.

if using:
Main.NavControl.ShowPage(pg)
I must use Main.NavControl.RemoveCurrentPage to unload.
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
I've created a small example with a page implemented in a class module.
Each time a new class (and page) are created.

Note the usage of WeakRef to assure that the class instance is kept together with the page.


Make sure that the animation is set to 0 in the layout file.

So in this example how do you respond to click events of views? From Main?
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
In the class module.

I must be doing something wrong. Like Arf, I moved my Code module into a Class and all of my click events stopped registering. I could see the button images change from Pressed and non-pressed states, but none of the code in the respective subs fired
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
Actually now I'm finding that click events aren't being registered for views loaded via a layout file from Designer. Views added in code in the Class module will fire the click subs however. Bug?
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
Actually I deleted app off phone, did Clean Project, reinstalled and now seems to be working fine... :confused:
 
Upvote 0
Top