iOS Question B4i equivalant of Activity.Finish

cwt

Active Member
Licensed User
Longtime User
My B4i app takes the user to the main menu when they open the app - they must login by clicking the "Login" button on the main menu. The login screen is a separate window.

I want the app to automatically return to the main menu when the user logs in - this is easy in B4a by using Activity.Finish - it takes the user directtly back to the main menu.

How can I do the same thing in my B4i app - return to the previous screen?
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
My B4i app takes the user to the main menu when they open the app - they must login by clicking the "Login" button on the main menu. The login screen is a separate window.

I want the app to automatically return to the main menu when the user logs in - this is easy in B4a by using Activity.Finish - it takes the user directtly back to the main menu.

How can I do the same thing in my B4i app - return to the previous screen?
In Swift you can use
B4X:
self.dismiss(animated: Bool)
but I don't know if/how this is implemented in B4i.

- Colin.
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Disclaimer: I barely know what I'm talking about in this post. Just found something that I thought might help somehow.

In Swift you can use
B4X:
self.dismiss(animated: Bool)
As far as I can tell, this is the documentation for that:

And by changing the top right language dropdown from Swift to Objective-C we arrive at:

Perhaps it's possible to include this in an #IF OBJC to achieve what @cwt wanted?
 
Upvote 0

Filippo

Expert
Licensed User
Longtime User
My B4i app takes the user to the main menu when they open the app - they must login by clicking the "Login" button on the main menu. The login screen is a separate window.

I want the app to automatically return to the main menu when the user logs in - this is easy in B4a by using Activity.Finish - it takes the user directtly back to the main menu.

How can I do the same thing in my B4i app - return to the previous screen?
I don't know if this will help you, but I always do this in my apps:
When the login has been executed, then :

B4X:
Sub loginOut
    Main.NavControl.RemoveCurrentPage
    Main.ReturnFromPageX
End Sub

'In Main
Public Sub ReturnFromPageX
    NavControl.ShowPage(pMain)
    
    pnlRoot_Resize(pnlRoot.Width, pnlRoot.Height)
End Sub
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
You cannot show or return to the home screen programmatically (without using APIs not allowed by Apple).
Edit: Oops - sorry, my bad. The cases where I use dismiss are not returning to the main ViewController. I just ran a test on an app & you can use self.dismiss in a ViewController that is segued from the main ViewController & you won't get an error - but it won't do anything either. :)

=======================================================================================================================
Not sure I understand you correctly Erel. I have several apps that use self.dismiss in multiple ViewControllers & I've never had any of them rejected at app review. Or are you meaning something else?

- Colin.
 
Last edited:
Upvote 0
Top