
[英]Adding activity indicator to the detail view of a splitview controller
[英]Default detail view controller when splitview not collapsed
我正在使用UISplitView将iPad应用程序转换为通用应用程序。
在iPad上 ,该应用程序会在“主VC”(“表视图”)(用户的仪表板)中选中一个单元格,从而在该仪表板中填充详细信息VC。 该位已经完成。 供参考,代码可实现此目的:
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.section == 0 {
tableView.selectRow(at: indexPath, animated: false, scrollPosition: UITableView.ScrollPosition.none)
self.performSegue(withIdentifier: "showDashboard", sender: self)
}
}
在iPhone上 ,如果我以Portrait加载应用程序,则它将在Master TableView上启动(.isCollapsed = true)。 如果我将设备旋转到横向而未从Master TableView中选择任何内容,则isCollapsed = false,应用程序崩溃,因为显示详细信息VC时没有加载任何内容。 如何触发“ showDashboard” segue(如上所示),以在iPhone中更改设备方向时使用Dashboard填充详细信息VC,以便没有空白的详细信息VC? 我已经尝试了以下方法,但是没有运气...
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
if splitViewController?.isCollapsed == false {
let initialIndexPath = NSIndexPath(row: 0, section: 0)
self.tableView.selectRow(at: initialIndexPath as IndexPath, animated: true, scrollPosition:UITableView.ScrollPosition.none)
self.performSegue(withIdentifier: "showDashboard", sender: self)
}
}
任何帮助表示赞赏,谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.