イメージとラベルを表示したい。
SWIFTでTableViewCellを利用して
イメージとラベルを縦に表示したいと思い、
CustomTableViewCellを使っています。
またページを遷移させるためTabで画面切り替えができるようにしています。
1のページではイメージ等が表示されるのですが、
2のページではイメージ等が表示されず、真っ白になります。
CustomTableViewCellは1と2用に2つ作り
違いはCustomTableView1と名前だけです。
###発生している問題・エラーメッセージ
エラーメッセージが表示されない。
エラーメッセージ
###該当のソースコード
<ViewControllerのコードです。> import UIKit class SecondViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { let imageNames = ["futako.jpg", "fran.jpg", "fran.jpg", "yokado.jpg", "fran.jpg", "yokado.jpg"] let imageTitles = ["二子玉川", "フランフラン", "フランフラン", "ヨーカドー", "フランフラン", "ヨーカドー"] let imageDescriptions = [ "二子玉川公園を散歩", "フランフランにて", "フランフランにて", "ヨーカドーで・・・", "フランフランにて", "ヨーカドーで・・・" ] override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return imageNames.count } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("MyCell1") as! CustomTableViewCell1 cell.setCell(imageNames[indexPath.row], titleText: imageTitles[indexPath.row], descriptionText: imageDescriptions[indexPath.row]) return cell } } <CustomViewControllerCell1のコードです> import UIKit class CustomTableViewCell1: UITableViewCell { @IBOutlet weak var myImageView: UIImageView! @IBOutlet weak var myTitleLabel: UILabel! @IBOutlet weak var myDescriptionLabel: UILabel! override func awakeFromNib() { super.awakeFromNib() // Initialization code } override func setSelected(selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated) // Configure the view for the selected state } func setCell(imageName: String, titleText: String, descriptionText: String) { myImageView.image = UIImage(named: imageName) myTitleLabel.text = titleText myDescriptionLabel.text = descriptionText } }
###試したこと
イメージの大きさや場所を変えてみました。
###補足情報(言語/FW/ツール等のバージョンなど)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/09/02 10:56
2016/09/02 12:20
2016/09/03 10:31
2016/09/05 10:32