BulletinBoard
BulletinBoard copied to clipboard
Presenting & Instantiate VC
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