Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 使用Swift在MainstryBoard表视图中显示数组?_Arrays_Uitableview_Swift_Tableview - Fatal编程技术网

Arrays 使用Swift在MainstryBoard表视图中显示数组?

Arrays 使用Swift在MainstryBoard表视图中显示数组?,arrays,uitableview,swift,tableview,Arrays,Uitableview,Swift,Tableview,我可以用Swift语言创建一个数组。但是,能够映射这个数组以显示在iOS上的Main.storyboard中,这就是我画空白的地方。我理解可以有TableViewControllers和TableViews和TableViewCells,但不知何故,我无法从 myArray ["Viktor Schauberger", "Nikola Tesla", "Wilhelm Reich", "John Bedini", "Walter Russell", "Ed Leedskalnin", "R.

我可以用Swift语言创建一个数组。但是,能够映射这个数组以显示在iOS上的Main.storyboard中,这就是我画空白的地方。我理解可以有
TableViewController
s和
TableView
s和
TableViewCell
s,但不知何故,我无法从

 myArray ["Viktor Schauberger", "Nikola Tesla", "Wilhelm Reich", "John Bedini", "Walter Russell", "Ed Leedskalnin", "R. Buckminster Fuller", "John Keely", "Nathan Stubblefield", "Ismael Aviso", "Hector Perez Torres", "Thomas Henry Moray"]
能够在iOS模拟器中显示,然后从显示一系列内容到使其可点击。但就目前而言,我只想知道如何使用Swift 1.2在
TableView
/
TableViewController
中直观地显示此数组,以适用者为准

override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath:indexPath) as MyCell
    // no "if" - the cell is guaranteed to exist
    // ... do stuff to the cell here ...
    cell.textLabel.text = self.Myarray objectAtIndex:indexPath.row;
    // ...
    return cell
}
试试这个:)

或者转到下面的链接,这可能会对您有所帮助

用于加载原型单元

我认为您遇到的快速问题不如UIKit问题严重。我建议阅读有关
UITableViewDataSource
UITableViewDelegate
协议如何工作的详细信息。Sarath,请问我应该将这段代码放在哪里?:)您好,我尝试将myArray和您的信息添加到其中,并在cell.textLabel.text=self.myArray objectAtIndex:indexPath.row上得到了一个“行上的连续语句必须用分隔符分隔;”;总的来说,我感到非常困惑。此外,此处还表示“tableview(u:CellForRowatineXpath:)的结果和参数的可选性与协议UITableViewDataSource所预期的不同。此外,“使用未声明的类型‘MyCell’。。等等,“MyCell”是我在项目中创建的自定义单元格的名称。如果您正在加载任何自定义单元格或其他内容,您可以使用该名称而不是MyCell,如果您使用的是prototype单元格。我认为索引路径中的行的noramal单元格是SUPPLICENTABLEVIEW(tableView:UITableView!,cellForRowAtIndexPath:NSIndexPath!)->UITableViewCell!