导航到另一个ViewController时,UITableView行存在错误

时间:2018-09-18 07:36:56

标签: ios swift uitableview animation uiviewcontroller

我的应用程序中有一个TableView,它显示一些事件。当我单击它时,它导航到单击的事件。 我的挣扎是,整个导航过程/动画看起来非常难看。当新的ViewController已经存在时,行将消失。

我设法对其进行了屏幕截图,因此您可以更好地了解它的外观。 Tableview Navigation

代码如下:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    tableView.deselectRow(at: indexPath, animated: false)
    guard let parent = parentVC else { return }
    guard let id = twoDimensionalEventArray[indexPath.section].events[indexPath.row].eventID else { return }
    parent.gotoEvent(eventID: id)
}

func gotoEvent(eventID: Int) {
    let event = eventArray[eventID]
    let eventVC = SingleEventViewController(event: event)
    self.navigationController?.pushViewController(eventVC, animated: true)
}

有人知道如何解决这个问题吗?

因为两个人建议我提供SingleEventVuewController的Viedloading,所以它是:

init(event: Event) {
    thisEvent = event
    super.init(nibName: nil, bundle: nil)
    setupDefaultValues()
    self.view.backgroundColor = .white
}

override func viewDidLoad() {
    super.viewDidLoad()
    applyDefaultValues()
    setupNavBar()
    setupViews()
    confBounds()
    getSnapshotForLocation()
}

2 个答案:

答案 0 :(得分:1)

像在详细视图控制器的self.view.backgroundColor = .white中的viewDidLoad()一样将backgroundColor设置为白色,如果这样做的话,也可以在情节提要中对其进行设置。

答案 1 :(得分:0)

在情节提要中将单元格的背景颜色内容视图设置为白色。请参阅屏幕截图enter image description here