我是这里快速开发的新手,试图更改iOS 13的演示样式以使用push样式。原始资源使用情节提要为视图控制器设置演示样式,但是其中一部分使用[
覆盖 override func prepare(for segue: UIStoryboardSegue, sender: Any?)
我设法通过pushViewController进行了转换,但是应用立即崩溃了,请问这是什么问题?这是全功能
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let selectedIndex:Int? = menuTableView.indexPathForSelectedRow?.row
if (selectedIndex! == 0 || selectedIndex! == 1){
let submitViewController: SubmitViewController = segue.destination as! SubmitViewController
if (selectedIndex! == 0){
submitViewController.currency = Constant.CURRENCY_MYR
}else{
submitViewController.currency = Constant.CURRENCY_SGD
}
}else if (selectedIndex! == MENU_ACCOUNT_STATISTIC_INDEX){
let target: SearchResultViewController = segue.destination as! SearchResultViewController
target.toolbarOption = SearchResultViewToolBarOption.TOOLBAR_SMS
target.resultContent = self.resultContent
self.navigationController!.pushViewController(target, animated: true)
}
这是我得到的错误日志
2020-04-04 14:50:24.227072+0800 vboss[38120:1974490] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <vboss.MenuViewController: 0x7fd906087e00>.'
var selectedIndex : Int = -1
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.selectedIndex = indexPath.row
if (selectedIndex == 0 || selectedIndex == 1){
self.performSegue(withIdentifier: "submitViewController", sender: nil)
}else if (selectedIndex == MENU_ACCOUNT_STATISTIC_INDEX){
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let target = storyboard.instantiateViewController(withIdentifier: "searchResultViewController") as! SearchResultViewController
target.resultContent = self.resultContent
navigationController?.pushViewController(target, animated: true)
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let submitViewController: ViewController = segue.destination as! SubmitViewController{
if (selectedIndex == 0){
submitViewController.currency = Constant.CURRENCY_MYR
}else{
submitViewController.currency = Constant.CURRENCY_SGD
}
}
}