模拟器和iPhone之间的不同行为

时间:2017-03-09 15:50:05

标签: iphone swift datepicker

我在项目中使用DatePickerCell在表格视图控制器中使用了7个日期选择器单元格。我调整了它,所以如果我点击一个新的单元格,之前点击的单元格日期选择器将崩溃。当我在模拟器上运行应用程序时,一切都很顺利,并按照它应该的那样运行。当我在运行iOS 8.3的iPhone 5S上运行应用程序时,当我点击一个单元格时,2个单元格会扩展,其他奇怪的事情也会发生。这有什么不对?使用Xcode 8.2.1 Swift 3

这里是tableview的代码:

func dismissPreviousCell()
{
    if previousIndex != nil {
        let cellToDismiss = self.tableView(tableView, cellForRowAt: previousIndex!) as? DatePickerCell
        cellToDismiss?.selectedInTableView(tableView)
    }
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let cell = self.tableView(tableView, cellForRowAt: indexPath)

        if let datePickerCell = cell as? DatePickerCell {
            datePickerCell.selectedInTableView(tableView)
            print("Index path is \(indexPath)")
            dismissPreviousCell()
            previousIndex = indexPath
    }
    self.tableView.deselectRow(at: indexPath, animated: true)
}

0 个答案:

没有答案