テーブルをグループ化してnilを送信すると問題が発生しますが、すべてを1の配列として保持しても何の問題もなく、ここでは、nilを送信するグループ化されたテーブルビューのコードを示します。これは簡単な修正だと思います。おかげグループ化されたテーブルビューはnilを送信しますが、プレーンは完全に動作します
のViewController:
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var tableView: UITableView!
var runeTitle = [["Freyr/Freya's Aett"], ["Heimdall's Aett"], ["Tyr's Aett"], ["Additional Runes"]]
let runes = [[Rune(runeName: "Fehu", runeImage: UIImage(named: ("Fehu.png"))!, runeDescription: "(F: Domestic cattle, wealth.) Possessions won or earned, earned income, luck. Abundance, financial strength in the present or near future. Sign of hope and plenty, success and happiness. Social success. Energy, foresight, fertility, creation/destruction (becoming).\n\n Fehu Reversed or Merkstave: Loss of personal property, esteem, or something that you put in effort to keep. It indicates some sort of failure. Greed, burnout, atrophy, discord. Cowardice, stupidity, dullness, poverty, slavery, bondage.")],
[Rune(runeName: "Hagalaz", runeImage: UIImage(named: ("Hagalaz.png"))!, runeDescription: "(H: Hail.) Wrath of nature, destructive, uncontrolled forces, especially the weather, or within the unconscious. Tempering, testing, trial. Controlled crisis, leading to completion, inner harmony. Hagalaz Merkstave (Hagalaz cannot be reversed, but may lie in opposition): Natural disaster, catastrophe. Stagnation, loss of power. Pain, loss, suffering, hardship, sickness, crisis.")],
[Rune(runeName: "Blank Rune", runeImage: UIImage(named: ("Blank.png"))!, runeDescription: "There is no historical support for a \"Blank Rune\" in runic divination. It was invented in the 1980's. It should not be used in a rune casting. If you bought a rune set with a blank piece, save it in case you lose another rune piece, but don't use it in rune casting.")]]
func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return runes.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return runes[section].count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Configure the cell...
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as UITableViewCell;
let item = runes[indexPath.section][indexPath.row]
cell.imageView?.image = item.runeImage
cell.textLabel?.text = item.runeName
cell.accessoryType = UITableViewCellAccessoryType.disclosureIndicator
return cell
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return String(describing: runeTitle[section][0])
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "segue" {
let rune = sender as! Rune
let destinationVC = segue.destination as! SecondViewController
destinationVC.selectedRune = rune
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
}
SecondViewController:
import UIKit
class SecondViewController: UIViewController {
var selectedRune: Rune!
@IBOutlet weak var runeNameLabel: UILabel!
@IBOutlet weak var runeImage: UIImageView!
@IBOutlet weak var runeDescriptionLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
runeNameLabel.text = selectedRune.runeName
runeImage.image = selectedRune.runeImage
runeDescriptionLabel.text = selectedRune.runeDescription
}
}
あなたが「セグエ」にストーリーボードであなたのセグエ識別子を設定しましたか? – vacawama
'nil'を送信するものは?どこから送られましたか?あなたの質問は完全にはっきりしていません。 – rmaddy
申し訳ありません@rmaddyはい私の質問を読んで漠然としていました:)私のテーブルは、私の配列からセットアップしたグループに完全に移入しますが、私がSecondViewControllerにsegueして配列に格納されているすべての情報を表示するそれはnilを返します。私はこれが少し良く説明されることを願っています。申し訳ありません –