简体   繁体   English

NavigationController重新加载tableview

[英]moreNavigationController reload tableview

in swift 1.2 I use this code to reload morenavigationcontroller tableview: 在Swift 1.2中,我使用以下代码重新加载morenavigationcontroller tableview:

(tabBarController.moreNavigationController.topViewController?.view as! UITableView).reloadData()

after migrated to Swift 2 I get this error and cannot find a solution: 迁移到Swift 2后,出现此错误,找不到解决方案:

Could not cast value of type 'UIView' (0x11281d1c8) to 'UITableView' (0x11281dbf0). 无法将类型'UIView'(0x11281d1c8)的值强制转换为'UITableView'(0x11281dbf0)。

Any help is appreciated. 任何帮助表示赞赏。

Thanks, Max 谢谢,马克斯

It is not related to the version of Swift but rather to the version of iOS. 它与Swift的版本无关,而与iOS的版本有关。

Indeed, the documentation says that the moreNavigationController is a UINavigationController and not a UINavigationController whose topViewController 's view is a `UITableView. 实际上, 文档moreNavigationController是一个UINavigationController而不是一个UINavigationControllertopViewController的视图是一个UITableView。 Therefore Apple can change the implementation and the view hierarchy whenever they want. 因此,Apple可以随时更改实现和视图层次结构。

You should never rely on such assumptions because your code may crash even in minor updates. 您永远不要依赖这些假设,因为即使在较小的更新中您的代码也可能崩溃。 So, be careful doing that. 因此,请谨慎操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM