当我敲击CollectionView细胞didSelectItemAt立即调用indexPath方法,但在40-50秒之后调用。myNextViewController装上子弹了。你能告诉我为什么会有这样的延迟吗?请帮我移除这个。
override func viewDidLoad() {
super.viewDidLoad()
startLoader()
gatewayActionAlert.isHidden = true
renameActionAlert.isHidden = true
deleteActionAlert.isHidden = true
menuOptionsView.isHidden = true
viewInitialization()
commandMqtt = savedData.getSavedData(key: "mqttCommand")
responseMqtt = savedData.getSavedData(key: "mqttResponse")
getOwnerId=savedData.getSavedData(key: "ownerId") as String
let gatewayNameData = userDefaults.string(forKey: "gatewayName")
if gatewayNameData != nil {
data.append(gatewayNameData!)
}
getAllGatewayFromFirebase(ownerID: getOwnerId)
getAllSharedGatewayFromFirebase(ownerID: getOwnerId)
collectionview.dataSource=self
collectionview.delegate=self
NotificationCenter.default.addObserver(self, selector: #selector(reloadGateways), name: NSNotification.Name(rawValue: "reloadGatewayCollectionView"), object: nil)
refreshCollectionview()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
gatewayActionAlert.isHidden = true
renameActionAlert.isHidden = true
deleteActionAlert.isHidden = true
menuOptionsView.isHidden = true
collectionview.reloadData()
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if indexPath.section == 0 {
if gatewaysArray.count == 0 {
Common.showCancelAlert("Warning", message: "Please add a new Gateway to proceed", cancelTitle: "Ok", viewController: self)
} else {
let vc=storyboard?.instantiateViewController(withIdentifier: "AllNodeViewController")
self.navigationController?.pushViewController(vc!, animated: true)
}
}
if indexPath.section == 1 {
//sharedGatewaysArrayNames
if sharedGatewaysArrayNames.count == 0 {
Common.showCancelAlert("Warning", message: "There is no shared Gateway", cancelTitle: "Ok", viewController: self)
} else {
let vc=storyboard?.instantiateViewController(withIdentifier: "AllNodeViewController")
self.navigationController?.pushViewController(vc!, animated: true)
}
}
}
下面是我的NextViewController方法:
override func viewDidLoad() {
super.viewDidLoad()
nodeActionAlert.isHidden = true
renameActionAlert.isHidden = true
deleteActionAlert.isHidden = true
gatewayDetailsAlert.isHidden = true
gatewayVersionButton.isHidden = true
gatewayVersionButton.layer.cornerRadius = 5
gatewayVersionButton.fadeOut()
collectionViewNodes.dataSource=self
collectionViewNodes.delegate=self
mqttSession.delegate=self
viewInitialization()
mqttConstantsAccess()
refreshCollectionview()
hideKeyboardWhenTappedAround()
if checkReachabilty() {
self.publishData(parameters: "#BA&")
startLoader()
getNodeFromFirebase(ownerID: getOwnerId, gatewayID: getGatewayId)
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
nodeActionAlert.isHidden = true
renameActionAlert.isHidden = true
deleteActionAlert.isHidden = true
gatewayDetailsAlert.isHidden = true
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。