Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Presenting & Instantiate VC #134

Open
Mindkind-Dev opened this issue Nov 15, 2018 · 0 comments
Open

Presenting & Instantiate VC #134

Mindkind-Dev opened this issue Nov 15, 2018 · 0 comments

Comments

@Mindkind-Dev
Copy link

Hi,

it could be very interesting to be able to instantiate a VC instead of presenting above when having BLTN Pages in separate files.

Situation:
Actually im building an app that scan for BLE peripherals, then connect to it. The initial page is the scanning page, then once discovered a bulletin page appear asking if the user want to connect. If yes the connection is established and the mainApp VC is presented.

Only possible way:
It is possible to instantiate VCs using self.present(...) into the actionHandler only if the bulletin board code is in the VC's class itself. However, when you separate the boards in different swift files, it's not possible. It is also not possible to use the dismissBulletin, because it's above.

Instantiate VCs -> With all the code inside the VC's class:

page.actionHandler = { (item: BLTNActionItem) in
            item.manager?.dismissBulletin(animated: true)
            
            if let toVC = self.storyboard?.instantiateViewController(withIdentifier: myStoryboardIDs.mainAppTabBar.rawValue){
                self.present(toVC, animated: true, completion: nil)
            }
        }

Presenting Above -> In separate swift files:

page.actionHandler = { (item: BLTNActionItem) in
            let toVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: myStoryboardIDs.mainAppTabBar.rawValue)
            item.manager?.present(toVC, animated: true, completion: nil)
        }

You may ask yourself why I want them in separate file? Simply to use the same BLTN Page when needed everywhere in my app.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant