【发布时间】:2018-02-27 17:28:57
【问题描述】:
我正在编写一个函数,当我的应用程序在本地接收到远程通知时将调用该函数。首先,使用库 BRYXBanner 显示横幅,然后当用户点击横幅时,它将调用此函数,该函数应显示名为 ChatLogViewController 的视图控制器。可以从应用程序中的任何位置调用此函数,因此该函数的参数之一是 fromViewController。我正在尝试找出两个问题。
- 如何使用函数 GoToChatLogVC() 从应用程序内的任何位置呈现 ChatLogViewController
代码:
func GoToClassVC(fromVC : UIViewController, toClassID: String) {
let chatLog = ChatLogViewController()
fromVC.present(chatLog, animated: true) {
chatLog.classID = toClassID
}
}
- 如何将此函数分配给 (()->()) 类型的属性?
guard let currentVC = self.window?.currentViewController() else {
print("ERROR")
return
}
let banner = Banner(title: title, subtitle: body, image: #imageLiteral(resourceName: "MessageIcon"), backgroundColor: UIColor(red:40.00/255.0, green:170.0/255.0, blue:226/255.0, alpha:1.000))
banner.show(duration: 3.0)
banner.didTapBlock = GoToClassVC(fromVC: currentVC, toClassID: self.backgroundLaunchClassID)
感谢您的帮助!
【问题讨论】:
-
使用通知并通过通知对象向相关视图控制器发出信号。
标签: ios swift uiviewcontroller appdelegate