- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个具有 3 个 View 的应用程序。第一个是主菜单,第二个是这个(歌曲名称列表)。我有 800 个标题要显示。我想实现一个显示所有这些标题的表格 View 。当我尝试运行构建时,构建是正确的,但是当我转到 tableview 的 View 时,我在 iPhone 上只看到黑屏。我尝试了很多次,我发现了这一点:如果我从 iPhone 中删除我的应用程序,并且我第一次调整它,一切正常,但如果我尝试运行第二个,屏幕是黑色的。我试过我的 iPhone X 和模拟器。有什么问题吗?
我的第二个问题是:是否可以将我所有的数组存储到另一个文件中而不是在 TableViewController 中?感谢大家。
import UIKit
class TableViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
//Creo le sezioni
let sections = ["A","B","C","D","E","F","G",]
//Creo i vari Array divisi per lettere
let cantiA: [String] = ["A BRUSA SÜTA ‘L SUSA","A DESTRA DELL’ISONZO","A FERRO FREDDO","A L’È SIRA","A L’OSPEDAL DI GENOVA","A LA MATIN BONURA","A LA MODA D’II MÔNTAGNÔN","A LA TOR VANGA","A MASSAUA","A MEZZANOTTE IN PUNTO","A PLAN CALE IL SORELI","A VAN I BRAVI ALPIN","A’ VAN SISÌLIS","ABANDONO","ABBIAM LE SCARPE GROSSE","ADAMELLO","ADDIO CARA MAMMA","ADDIO MIA BELLA, ADDIO","ADDIO NINETTA","ADESSO DORMI","ADUA","AI COMANDI","AI MORTI PER LA PATRIA","AI PREÂT","AL CJANTE IL GIÂL","AL COLONNELLO TINIVELLA","AL COMANDO DEI NOSTRI UFFICIALI","ALL’ALPINO D’ITALIA","ALL’ARMI, ALL’ARMI BERSAGLIERI","ALLA MATTIN","ALLA MATTINA","ALLA MATTINA SI GH’È ‘L CAFÈ","ALLA PRESA DEL CAVENTO","ALPIN JO MAME","ALPINI","ALPINI DELL’OROBICA","ALPINI IN MONTAGNA","ALPINI MITRAGLIERI","ALPINO DELLA JULIA","ALPINO MIO BELL’ALPINO","ALPINO PARTIGIANO","AMA CHI T’AMA","AMA IL VECCHIO","AMICI MIEI","AMILCARE","AMMORE AMMORE","AN VAL DONDONA","ANCHE MIO PADRE","ANCHE SE PESA","ANCORA ‘STI QUATRO","ANDOUMA PROU","ANDREMO IN FRANCIA","APPENA SUL PASUBIO","APRI LA PORTA","APRILE SENZA UN FIORE","APRITE LE PORTE","ARDA BÈRGHEM","ARSO","ARTIGLIERE","ASCOLTATE AMICI CARI","ATTRAVERSO VALLI E MONTI","AU MONT BLANC","AUGELLIN DI PRIMAVERA","AVE, O VERGINE","AVER ‘NA FIGLIA SOLA SOLETA","AVEVA QUINDICI ANNI","AYAS","AZZURRI MONTI"]
let cantiB: [String] = ["BALDI E FORTI"]
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("section: \(indexPath.section)")
print("row: \(indexPath.row)")
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return sections[section]
}
func numberOfSections(in tableView: UITableView) -> Int {
return sections.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case 0:
// Fruit Section
return cantiA.count
case 1:
// Vegetable Section
return cantiB.count
default:
return 0
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Create an object of the dynamic cell “PlainCell”
let cell = tableView.dequeueReusableCell(withIdentifier: "PlainCell", for: indexPath)
// Depending on the section, fill the textLabel with the relevant text
switch indexPath.section {
case 0:
// Fruit Section
cell.textLabel?.text = cantiA[indexPath.row]
break
case 1:
// Vegetable Section
cell.textLabel?.text = cantiB[indexPath.row]
break
default:
break
}
return cell
}
}
最佳答案
我不确定,但我认为您的问题出在第一行,您在其中将 TableViewController 声明为 UIViewController 的子类。 UITableViewController 的子类不应该有一个 UITableView 来填充数据吗?
你有:
class TableViewController: UIViewController, ...
也许这有帮助:
class TableViewController: UITableViewController {
关于arrays - 黑屏的tableview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50221666/
我正在学习微处理器类(class),但我的代码有问题。 我需要编写一个程序代码,让一个词四处移动。 代码在 (80*25) 屏幕上正常工作(因为我的计算依赖于它) 但问题是:当我最大化显示屏幕时,一切
尝试使用 exoplayer v2.10.5 播放 m3u8 时变黑,这让我添加了或者我如何使用 exoplayer v2.10.5 和 gradle 3.5.3 播放 m3u 或者哪个版本的 exo
有几个现有的例子,但我想要一个使用 complex_filter 来实现目标的命令,而不需要做额外的事情,比如生成空白视频/音频文件。 环顾四周,这是迄今为止我想出的最好的: ffmpeg -i vi
服务是“允许服务与桌面交互”。 unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls,
我有一个显示youtube的本地ios应用程序,直到昨天该应用程序运行良好,但是现在该应用程序显示了youtube,只有当我触摸“播放”而不是播放视频时,它才显示黑屏。 我的应用程序没有更改,因此我认
我正在尝试向我的游戏添加一些基本的 HUD,但是当我尝试更改视角时,我可以看到文本(我之前提到过 HUD),但是在黑屏上。问题出在哪里? gl.glMatrixMode(GL_PROJ
我的转换不起作用,第一个 ImageView 显示了可绘制对象,但在运行动画时它只是以白屏结束。不确定我错过了什么。 主要布局 第二个 Activity 布局 主要 Activity pu
出于某种原因,当我尝试运行此代码时,我得到的只是黑屏。我怎样才能真正让它显示我想要显示的内容? 我正在使用 Eclipse,并且已将 lwjgl.jar 和 lwjgl_utils.jar 添加到构建
我正在遵循有关构建“弹出锁类型”游戏的教程,当我在模拟器中运行它时,会出现黑屏。我之前查过并尝试重置模拟器并重新启动计算机,但它不起作用有人可以帮助我并告诉我为什么会发生这种情况 import Spr
我正在尝试 MrSnakey 游戏。当我运行它时,它没有给我任何错误。但是,模拟器在启动时显示黑屏。你们不知道如何解决吗?解决此问题所需的有关我的项目的任何信息,请告诉我,我会在此处发布。 首先是 l
所以我遇到了相机卡住的问题。当它第一次被调用时,它工作得很好。并在按钮上显示我的图像。但是,如果我回到同一个按钮再次调用相机,或者调用相机的页面上的任何其他按钮,它会启动相机但不是黑屏。相机实际上并没
我几乎阅读了关于这个主题的所有帖子,但似乎没有一个有帮助。 我正在 try catch 当前屏幕的屏幕截图。为此,我正在使用 getDrawingCache。这是我的代码: mRootView.get
我已经用我命名为 Label 的类实现了 CCLabelProtocol 和 CRGBAProtocol: #import @interface Label : CCNode @property
晚上好。我为 iOS 开发了几年,自从 iOS8 发布以来,我遇到了一个奇怪的问题。我确信它会被修复,但现在是 8.1.2,而且它还在发生。在 iOS7 上一切正常,但在运行 iOS8 的手机上发生了
这是我的完整代码。当我右击几次(动画正常工作)时,屏幕卡住。我认为来自 if(SDL_GetTicks() - start_time format, 0, 0xFF, 0xFF ) );
我需要执行以下操作: 用户登录。 重定向至欢迎屏幕。 在加载大量记录时查看欢迎屏幕。 重定向到工作屏幕。 我正在寻找一种在 Action 类中执行类似操作的方法: public class LinkA
我在 KMZ 文件中有一个坐标数据集,我希望能够为用户提供使用 GMSPanoramaView(使用 1.6.0 版本的 Google-Maps-iOS-SDK)查看街景的选项).这是我的代码的样子:
在尝试将应用内 HTML 页面加载到我们的 UIWebView 时,我在 iOS9 上遇到了奇怪的行为 - 有时页面加载,有时只是显示为空白屏幕。 webViewDidFinishLoad 函数也在这
我试图显示我的收藏 View ,但我得到的只是黑屏。我知道我在某处遗漏了一些东西,但我似乎找不到它是什么。 #import "StoreCollectionViewController.h" #imp
我正在尝试从我们的 iOS 应用程序中删除所有 Storyboard,因为在使用 Git 的团队中工作时它们会变得一团糟。 我现在在 AppDelegate 的 application(_:didFi
我是一名优秀的程序员,十分优秀!