- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发 tvos 应用程序,它在 10.1(较新版本)上运行良好,但在我运行以前版本 (10.0) 时出现错误刷新后(1 分钟)。
error message is
我的代码是
NewsViewController
import UIKit
import Kingfisher
private let reuseIdentifier = "trenddingCell"
private let reuseIdentifierRegular = "regularCell"
class NewsViewController: UICollectionViewController {
@IBOutlet var mainCollectionView: UICollectionView!
let appDelegate = UIApplication.shared.delegate as! AppDelegate
var backgroundMessageLabel:UILabel?
var focusFlag:Bool = false
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(NewsViewController.presentController(_:)), name: NSNotification.Name(rawValue: "videoInfo"), object: nil)
let menuPressRecognizer = UITapGestureRecognizer()
menuPressRecognizer.addTarget(self, action: #selector(NewsViewController.menuButtonAction(_:)))
menuPressRecognizer.allowedPressTypes = [NSNumber(value: UIPressType.menu.rawValue as Int)]
self.view.addGestureRecognizer(menuPressRecognizer)
self.tabBarController?.tabBar.preferredFocusedView
self.setNeedsFocusUpdate()
self.updateFocusIfNeeded()
}
func menuButtonAction(_ ges:UITapGestureRecognizer){
self.tabBarController?.tabBar.canBecomeFocused
self.tabBarController?.preferredFocusedView
self.tabBarController?.setNeedsFocusUpdate()
self.tabBarController?.updateFocusIfNeeded()
}
override func viewWillAppear(_ animated: Bool) {
if appDelegate.dataFeedDetail.feedType == "J" || appDelegate.dataFeedDetail.feedType == "L"{
self.title = "ON DEMAND"
}
else{
self.title = "ON DEMAND"
}
//WebTrends().eventForTabBarItemFocus("News", menu: "news")
WebTrends().eventForTabBarItemFocus("News", channelName: "", menu: "news")
appDelegate.viewController = self
appDelegate.playerViewController = self
if appDelegate.categoryNewsArray.count == 0{
addBackgroundMessageLabel()
}else{
removeBackgroundMessage()
mainCollectionView.isHidden = false
if !focusFlag{
mainCollectionView.reloadData()
}
}
focusFlag = false
}
func loadNewData() {
DispatchQueue.main.async(execute: { () -> Void in
if self.appDelegate.categoryNewsArray.count > 0 {
self.removeBackgroundMessage()
self.mainCollectionView.isHidden = false
self.mainCollectionView.reloadData()
}
})
}
// MARK: - Collection Data Source.
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
print("begin numberOfItemsInSection")
return appDelegate.categoryNewsArray.count
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
print("begin cellForItemAt")
if indexPath.item == 0{
let cellTrendding = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! TrendingCollectionCell
let trindingValue = appDelegate.categoryNewsArray.object(at: indexPath.item) as! NSMutableDictionary
cellTrendding.trenddingLabelView.text = trindingValue.object(forKey: "title") as? String
print("end cellTrendding")
return cellTrendding
}else{
let cellRegular = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifierRegular, for: indexPath) as! RegularCollectionCell
let trindingValue = appDelegate.categoryNewsArray.object(at: indexPath.item) as! NSMutableDictionary
cellRegular.categoryLabelView.text = trindingValue.object(forKey: "title") as? String
print("end cellRegular")
return cellRegular
}
}
// MARK: - CollectionViewDelegate.
override func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
print("begin willDisplay")
if indexPath.item == 0{
guard let cell = cell as? TrendingCollectionCell else { fatalError("Expected to display a `TrendingCollectionCell`.") }
let trending = appDelegate.categoryNewsArray.object(at: indexPath.item)
cell.configureWithDataItems(trending as! NSMutableDictionary, jIndex: indexPath.item)
}else{
guard let cell = cell as? RegularCollectionCell else { fatalError("Expected to display a `RegularCollectionCell`.") }
let trending = appDelegate.categoryNewsArray.object(at: indexPath.item) as! NSMutableDictionary
print("appDelegate.categoryNewsArray====================\(trending.count)")
cell.configureWithDataItems(trending, jIndex: indexPath.item)
}
print("end willDisplay")
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
print("begin layout")
if indexPath.item == 0 {
return CGSize(width: view.frame.width, height: 410)
}else{
return CGSize(width: view.frame.width, height: 320)
}
}
override func collectionView(_ collectionView: UICollectionView, canFocusItemAt indexPath: IndexPath) -> Bool{
print("begin canFocusItemAt\(indexPath.item)")
return false
}
override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
}
// MARK: - Present Controller.
func presentController(_ notification:Notification) {
print("begin presentController")
let notificationData:NSDictionary = NSDictionary(dictionary: notification.userInfo!)
focusFlag = true
let playerVC = self.storyboard?.instantiateViewController(withIdentifier: "VideoPlayerViewController") as! VideoPlayerViewController
playerVC.videoIdentifier = "NewsView"
playerVC.videoCategoryNameandTitle = notificationData.object(forKey: "channelname") as! String as NSString
playerVC.navigationName = "News/\(notificationData.object(forKey: "channelname") as! String)" as NSString
playerVC.indexPath = notificationData.object(forKey: "indexpath") as! Int
playerVC.seriesShowDfpUrl = notificationData.object(forKey: "dfptag") as! String as NSString!
playerVC.seriesShows_Array = notificationData.object(forKey: "metaData") as! NSArray
playerVC.videoMaxShow = notificationData.object(forKey: "max_show") as! String
playerVC.adInterval = notificationData.object(forKey: "adinterval") as! Int
playerVC.modalPresentationStyle = UIModalPresentationStyle.fullScreen
playerVC.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
self.view.window?.rootViewController?.present(playerVC, animated: true, completion: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
KingfisherManager.shared.cache.clearMemoryCache()
KingfisherManager.shared.cache.clearDiskCache()
}
func addBackgroundMessageLabel(){
if backgroundMessageLabel == nil {
backgroundMessageLabel = UILabel(frame: CGRect.zero)
backgroundMessageLabel!.center = view.center
backgroundMessageLabel! = backgroundMessageLabel!.setLabelView(backgroundMessageLabel!, message: kNoDataMessage )
self.view.addSubview(backgroundMessageLabel!)
NSLayoutConstraint(item: backgroundMessageLabel!, attribute: NSLayoutAttribute.centerX, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.centerX, multiplier: 1, constant: 0).isActive = true
NSLayoutConstraint(item: backgroundMessageLabel!, attribute: NSLayoutAttribute.centerY, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.centerY, multiplier: 1, constant: 0).isActive = true
}
}
func removeBackgroundMessage(){
if self.backgroundMessageLabel != nil {
self.backgroundMessageLabel!.removeFromSuperview()
self.backgroundMessageLabel = nil
}
}
}
extension UILabel {
func setLabelView(_ label:UILabel, message:String) -> UILabel {
let backgroundMessageLabel = label
backgroundMessageLabel.text = message
backgroundMessageLabel.textAlignment = .center
backgroundMessageLabel.font = UIFont(name: "SFUIDisplay-Regular", size: 32.0)
backgroundMessageLabel.textColor = UIColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1.0)//UIColor.whiteColor()
backgroundMessageLabel.backgroundColor = .clear
backgroundMessageLabel.translatesAutoresizingMaskIntoConstraints = false
return backgroundMessageLabel
}
}
RegularCollectionCell
import UIKit
import Kingfisher
private let cellId = "appCellId"
class RegularCollectionCell: UICollectionViewCell, UICollectionViewDataSource, UICollectionViewDelegate {
@IBOutlet var categoryCollectionView: UICollectionView!
@IBOutlet var categoryLabelView: UILabel!
let appDelegate = UIApplication.shared.delegate as! AppDelegate
var dataItems = NSMutableDictionary()
var jsonIndex:Int!
// MARK: Configuration.
func configureWithDataItems(_ dataItems: NSMutableDictionary, jIndex:Int) {
self.dataItems = dataItems
categoryCollectionView.reloadData()
// categoryCollectionView.remembersLastFocusedIndexPath = true
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
let seriesShows_Array = self.dataItems.value(forKey: "max_shows") as? String
let topVideos = self.dataItems.value(forKey: "datafeed") as? NSArray
if seriesShows_Array != "" {
if topVideos!.count > Int(seriesShows_Array!)! {
return Int(seriesShows_Array!)! as Int
}
}
if topVideos != nil && topVideos!.count > 0{
print("Crash numberOfItemsInSection",topVideos!.count)
return topVideos!.count
}else{
return 0
}
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
print("begin cellForItemAt")
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) as! CustomCollectionCell
let topVideos = (self.dataItems.value(forKey: "datafeed") as! NSArray).object(at: indexPath.item) as! JsonModel
cell.custom_LabelView.text = topVideos.videoTitle as String
let thumnailURL = topVideos.videoThumbnail as String
print("thumnailURL",thumnailURL)
let validUrl = thumnailURL.checkValidUrl(thumnailURL as String)
print("validUrl",validUrl)
let url = URL(string: validUrl)
print("url",url!)
cell.custom_ImageView.kf.setImage(with: url!, placeholder: UIImage(named: "not_found"), options: [.transition(ImageTransition.fade(0.5))], progressBlock: nil, completionHandler: nil)
cell.custom_LabelView.fadeLength = 100.0
cell.custom_LabelView.shutdownLabel()
print("end cellForItemAt")
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let dfpTag:String = self.dataItems.object(forKey: "dfp_tag") as! String
let adIntervalStr = self.dataItems.object(forKey: "ad_interval") as! String
let adInterval:Int!
if adIntervalStr == ""{
adInterval = 0
}else{
adInterval = Int(adIntervalStr)
}
let channelNameStr:NSString = self.dataItems.object(forKey: "title") as! String as NSString
let topVideos = self.dataItems.value(forKey: "datafeed") as! NSArray
let maxShow = self.dataItems.value(forKey: "max_shows") as! String
var tempDict: NSDictionary = [NSString:AnyObject]() as NSDictionary
tempDict = ["channelname": channelNameStr, "indexpath": indexPath.item, "dfptag": dfpTag, "adinterval": adInterval, "metaData": topVideos, "max_show": maxShow]
NotificationCenter.default.post(name: Notification.Name(rawValue: "videoInfo"), object: nil, userInfo:tempDict as? [AnyHashable: Any])
}
}
最佳答案
终于解决了这个问题。
替换
self.mainCollectionView.reloadItems(at: self.mainCollectionView.indexPathsForVisibleItems)
来自
self.mainCollectionView.reloadata
关于swift - tvos 10.0 出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42526127/
我已经使用 vue-cli 两个星期了,直到今天一切正常。我在本地建立这个项目。 https://drive.google.com/open?id=0BwGw1zyyKjW7S3RYWXRaX24tQ
您好,我正在尝试使用 python 库 pytesseract 从图像中提取文本。请找到代码: from PIL import Image from pytesseract import image_
我的错误 /usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference
我已经训练了一个模型,我正在尝试使用 predict函数但它返回以下错误。 Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]])
根据Microsoft DataConnectors的信息我想通过 this ODBC driver 创建一个从 PowerBi 到 PostgreSQL 的连接器使用直接查询。我重用了 Micros
我已经为 SoundManagement 创建了一个包,其中有一个扩展 MediaPlayer 的类。我希望全局控制这个变量。这是我的代码: package soundmanagement; impo
我在Heroku上部署了一个应用程序。我正在使用免费服务。 我经常收到以下错误消息。 PG::Error: ERROR: out of memory 如果刷新浏览器,就可以了。但是随后,它又随机发生
我正在运行 LAMP 服务器,这个 .htaccess 给我一个 500 错误。其作用是过滤关键字并重定向到相应的域名。 Options +FollowSymLinks RewriteEngine
我有两个驱动器 A 和 B。使用 python 脚本,我在“A”驱动器中创建一些文件,并运行 powerscript,该脚本以 1 秒的间隔将驱动器 A 中的所有文件复制到驱动器 B。 我在 powe
下面的函数一直返回这个错误信息。我认为可能是 double_precision 字段类型导致了这种情况,我尝试使用 CAST,但要么不是这样,要么我没有做对...帮助? 这是错误: ERROR: i
这个问题已经有答案了: Syntax error due to using a reserved word as a table or column name in MySQL (1 个回答) 已关闭
我的数据库有这个小问题。 我创建了一个表“articoli”,其中包含商品的品牌、型号和价格。 每篇文章都由一个 id (ID_ARTICOLO)` 定义,它是一个自动递增字段。 好吧,现在当我尝试插
我是新来的。我目前正在 DeVry 在线学习中级 C++ 编程。我们正在使用 C++ Primer Plus 这本书,到目前为止我一直做得很好。我的老师最近向我们扔了一个曲线球。我目前的任务是这样的:
这个问题在这里已经有了答案: What is an undefined reference/unresolved external symbol error and how do I fix it?
我的网站中有一段代码有问题;此错误仅发生在 Internet Explorer 7 中。 我没有在这里发布我所有的 HTML/CSS 标记,而是发布了网站的一个版本 here . 如您所见,我在列中有
如果尝试在 USB 设备上构建 node.js 应用程序时在我的树莓派上使用 npm 时遇到一些问题。 package.json 看起来像这样: { "name" : "node-todo",
在 Python 中,您有 None单例,在某些情况下表现得很奇怪: >>> a = None >>> type(a) >>> isinstance(a,None) Traceback (most
这是我的 build.gradle (Module:app) 文件: apply plugin: 'com.android.application' android { compileSdkV
我是 android 的新手,我的项目刚才编译和运行正常,但在我尝试实现抽屉导航后,它给了我这个错误 FAILURE: Build failed with an exception. What wen
谁能解释一下?我想我正在做一些非常愚蠢的事情,并且急切地等待着启蒙。 我得到这个输出: phpversion() == 7.2.25-1+0~20191128.32+debian8~1.gbp108
我是一名优秀的程序员,十分优秀!