微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

检测 NSTabview 何时在 Swift 中重新加载

如何解决检测 NSTabview 何时在 Swift 中重新加载

每当 tableview 项目计数为零时,我都会尝试向窗口添加标签。我认为最好的方法是在 tableview reloads 之后检查 // set the image imageView.image = img // get the aspect ratio let m = img.size.height / img.size.width // add new aspect ratio constraint to the image view // because this constraint will have (by default) a Priority of required (1000),// it will "override" the Storyboard 16:10 constraint that has Priority: 750 self.imageView.heightAnchor.constraint(equalTo: self.imageView.widthAnchor,multiplier: m).isActive = true // animate the size change UIView.animate(withDuration: 0.3,animations: { [weak self] in guard let self = self else { return } self.view.layoutIfNeeded() }) 。但是,当 tableview 重新加载时,我似乎找不到检测它的方法。有没有办法做到这一点?

解决方法

表视图不会自发地重新加载。你告诉他们什么时候重新加载。您可能应该有一个中央数据模型对象,并在项目数达到零时通知您的视图控制器。 (例如,您可以将数据模型对象设置为具有委托,并为委托提供 itemCountChanged(to:) 方法。)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。