1

I am trying to add multiple card views through storyboard. I link the up to code with IBOutlet and add the title view and detail view. Once i run the app and go to the CardViews, the app crashes giving me the "Thread 1:EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)" The first CardView (grammarCard) works fine but the second does not (vocabCard).

Here is the code

import UIKit

import Material

class StudyViewController: UIViewController {

@IBOutlet weak var vocabCard: CardView!

@IBOutlet weak var grammarCard: CardView!
override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.

    // Grammar Card Title
    let gTitleLabel:UILabel = UILabel()
    gTitleLabel.text = "Grammar"
    gTitleLabel.textColor = MaterialColor.deepPurple.darken1
    grammarCard.titleLabel = gTitleLabel
    // Grammar Card Detail
    let detailLabel: UILabel = UILabel()
    detailLabel.text = "Learn"
    detailLabel.numberOfLines = 0
    grammarCard.detailView = detailLabel
    // Start button
    let button: FlatButton = FlatButton()
    button.pulseColor = MaterialColor.deepPurple.lighten1

    button.pulseScale = false
    button.setTitle("Start", forState: .Normal)
    button.setTitleColor(MaterialColor.deepPurple.darken1, forState: .Normal)
    // Adding Buttons

    grammarCard.rightButtons = [button]
    //THIS ONE IS FINE

    // Do any additional setup after loading the view.

    // Vocab Card Title
    let vTitleLabel:UILabel = UILabel()
    vTitleLabel.text = "Vocabulary"
    vTitleLabel.textColor = MaterialColor.deepPurple.darken1

    vocabCard.titleLabel = vTitleLabel // Here the issue pops up
    // Vocab Card Detail
    let vdetailLabel: UILabel = UILabel()
    vdetailLabel.text = "Learn the words of "
    vdetailLabel.numberOfLines = 0
    vocabCard.detailView = vdetailLabel // Here the issue pops up
    // Start button
    let vbutton: FlatButton = FlatButton()
    vbutton.pulseColor = MaterialColor.deepPurple.lighten1

    vbutton.pulseScale = false
    vbutton.setTitle("Start", forState: .Normal)
    vbutton.setTitleColor(MaterialColor.deepPurple.darken1, forState: .Normal)
    // Adding Buttons

    vocabCard.rightButtons = [vbutton]


}

Thank you so much in advanced!

Akhil M
  • 21
  • 1
  • 2

1 Answers1

2

I am not seeing an issue in the code, so it is most likely with the setup in storyboards. So we added an example in 1.39.9 that uses two CardViews and storyboards. You can find this in the Examples/Storyboards directory.

All the best!

CosmicMind
  • 1,499
  • 1
  • 10
  • 6