【发布时间】:2018-12-13 17:38:13
【问题描述】:
今天我拆分了我的故事板,现在我遇到了一个错误,我不知道如何解决它。
我有 1 个故事板(产品),其中包含来自第一个选项卡的所有 UIViewController,我有另一个故事板(购物车),其中包含来自第二个选项卡的所有 UIViewController。 我已经将 StoryBoard 入口点设置为所有导航控制器,我在 MainStoryboard 中设置了引用,我为每个 StoryBoard 引用设置了正确的故事板目标,我真的不知道我做错了什么。
这是我在启动应用程序时遇到的错误:
"Could not cast value of type 'ShoppingLand.CartViewController' (0x10d72a780) to 'ShoppingLand.ProductsViewController' (0x10d72a8c0)."
这是我崩溃的函数(在第一行崩溃):
// Append the selectedProducts into productsInCartArray using the TabBarController
func fetchSelectedProducts() {
let firstTabVC = ((self.tabBarController?.viewControllers![0] as! UINavigationController).viewControllers[0] as! ProductsViewController)
productsInCartArray = firstTabVC.selectedProductsArray
productPricesArray = firstTabVC.priceForSelectedProductsArray
getProductsPhotosArray = firstTabVC.googlePhotosArray
totalSum = productPricesArray.reduce(0, +)
}
这是我的 StoryBoard 的图片:
感谢您的宝贵时间!
【问题讨论】:
-
看起来
let firstTabVC = ((self.tabBarController?.viewControllers![0] as! UINavigationController).viewControllers[0])实际上返回了CartViewController
标签: ios swift uitabbarcontroller uistoryboard