iOS Question Issue with NavControl.RemoveCurrentPage

Haris Hafeez

Active Member
Licensed User
Longtime User
Hello All,

I have run into an issue with using the subject method call.

I have the following setup in my project:

Module 1: Main. This shows the main list UI
Module 2: Available Items Page. Shows a list of items. Each item on this page's list allows the user to specify a date by clicking a button/switch.
Module 3: Date Page. Shows the date page. The date page simply contains AnotherDatePicker. When the user selects a date or clicks Cancel, I want to take the user back to the previous page. This is when I call NavControl.RemoveCurrentPage.

However, this doesn't seem to work. Upon selecting a date, the date page will close but logs the following:

nested pop animation can result in corrupted navigation bar
Unbalanced calls to begin/end appearance transitions for Page (vc): Future Notes.
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

The above does point out that something is not quite right but it doesn't say where the issue is. As this message predicts, the nav bar does indeed get corrupted in that nothing happens when clicking on the Back button when module 2 is shown.

Can someone please point me in the right direction to resolve this?

Relevant code is below:

--DatePage--
B4X:
Sub page_Appear
    adp.Show
End Sub
Sub adp_Closed (Cancelled As Boolean, date As Long)
    AvailableGmailDraftsPage.ShownAfterDatePicked = True
    If Cancelled Then
'        Main.NavControl.RemoveCurrentPage 'go back to the available drafts page
        CallSubDelayed(Me,"ClosePage")
    Else
        AvailableItemsPage.DateSelected = True
        SelectedDate = DateTime.Date(date)
        SelectedTime = DateTime.Time(DateTime.Now+1*60*1000)

'        Main.NavControl.RemoveCurrentPage ' go back to the available drafts page for now. should go to time page instead
        CallSubDelayed(Me,"ClosePage")
    End If
End Sub

Sub ClosePage
    Main.NavControl.RemoveCurrentPage 'should go back seamlessly to the AvailableItemsPage
End Sub


Thanks.
 

Haris Hafeez

Active Member
Licensed User
Longtime User
This problem seems to have gone away without me making any change to the affected code. o_O
I did clean the project a few times between reporting this and now though.

Not sure what happened but am not complaining anyways :)
 
Upvote 0

Haris Hafeez

Active Member
Licensed User
Longtime User
Well.. as soon as i started to celebrate the disappearance of this, it came back with a vengeance. Now not just this, but my list (customlistview) is also not showing items :(
 
Upvote 0

Haris Hafeez

Active Member
Licensed User
Longtime User
I'm running the code you sent me. How can I reproduce the issue?
Please use the 'Email' tab from the bottom bar on the main screen. Log in using a gmail account and giving the app permission. Please ensure you have draft emails in your gmail account.

Once the list loads, click on the switch to bring up the date page. Then select a date to come back to the email list page. This will cause the nav bars to stop working and result in the warning/error statements above.

Thanks.
 
Upvote 0

Haris Hafeez

Active Member
Licensed User
Longtime User
Please try to reproduce it in a simpler project that doesn't require Gmail authentication.

OK. I will revert. However, I have noted that it mostly happens when I select a date on the date page. Not when I simply hit cancel on the date page and return.
 
Upvote 0

Haris Hafeez

Active Member
Licensed User
Longtime User
Please find attached a sample project that reproduces this problem.
 

Attachments

  • date_page_test.zip
    12.2 KB · Views: 219
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are two problems:
1. You should move this code out of the the If block: Main.NavControl.ShowPage(pg)
2. There is a bug in AnotherDatePicker that causes the event to be raised twice.
Remove this sub:
B4X:
Private Sub holder_Click
   btnCancel_Click
End Sub
It handles the click event after the touch event and then raises the event another time.
 
Upvote 0

Haris Hafeez

Active Member
Licensed User
Longtime User
Thanks. Point 2 resolves the issue.

Point 1 was just me putting it there as I created a quick project.

Thanks again.
 
Upvote 0
Top