来自UICollectionViewCell的Segue失败了吗?

时间:2014-12-24 16:15:59

标签: ios swift segue uicollectionviewcell didselectrowatindexpath

我有UICollectionView

class BoatMatchingGame: UICollectionViewController, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {

我还有一个针对不同ViewController的课程,我试图将其划分为:

class GameOutcome: UIViewController {
    @IBOutlet var gameOutcomeLabel: UILabel!
    var boatMatchingGame: BoatMatchingGame!

    override func viewDidLoad() {
        super.viewDidLoad()
        gameOutcomeLabel.text = gameOutcomeText
    }
}

BoatMatchingGame课程中,我有prepareForSegue方法:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    let gameOutcome = segue.destinationViewController as GameOutcome
    gameOutcome.boatMatchingGame = self;
}

didSelectItemAtIndexPath方法中,我想执行segue

switch indexPath.item {
    case 14:
        self.performSegueWithIdentifier("Quit Matching Game", sender: self)

我在故事板中设置了标识符"Quit Matching Game"。当我运行该程序并在cell 14处选择indexPath时,我在以下错误中遇到以下错误:Thread 1: EXC_BREAKPOINT (code=EXC_1386_BPT, subcode=0x0)0x202ebd8: popl %ebp

注意:我确实有一个标签在这个单元格中每秒都在变化。

谢谢!

以下是整个帖子:

libswiftCore.dylib`swift_dynamicCastClassUnconditional:
0x2080ba0:  pushl  %ebp
0x2080ba1:  movl   %esp, %ebp
0x2080ba3:  movl   0x8(%ebp), %eax
0x2080ba6:  testl  %eax, %eax
0x2080ba8:  je     0x2080bbb                 ; swift_dynamicCastClassUnconditional + 27
0x2080baa:  movl   0xc(%ebp), %ecx
0x2080bad:  movl   (%eax), %edx
0x2080baf:  nop    
0x2080bb0:  cmpl   %ecx, %edx
0x2080bb2:  je     0x2080bd8                 ; swift_dynamicCastClassUnconditional + 56
0x2080bb4:  movl   0x4(%edx), %edx
0x2080bb7:  testl  %edx, %edx
0x2080bb9:  jne    0x2080bb0                 ; swift_dynamicCastClassUnconditional + 16
0x2080bbb:  calll  0x2080bc0                 ; swift_dynamicCastClassUnconditional + 32
0x2080bc0:  popl   %eax
0x2080bc1:  leal   0x38262(%eax), %ecx
0x2080bc7:  movl   0x7748c(%eax), %eax
0x2080bcd:  movl   %ecx, 0x8(%eax)
0x2080bd0:  movl   $0x0, 0xc(%eax)
0x2080bd7:  int3   
0x2080bd8:  popl   %ebp
0x2080bd9:  retl   
0x2080bda:  nopw   (%eax,%eax)

1 个答案:

答案 0 :(得分:0)

您似乎还没有真实地声明或初始化gameOutcomeText GameOutcome {\ n} viewDidLoad中使用的gameOutcomeText变量。

如果在BoatMatchingGame类中设置BoatMatchingGame,则可以使用传递到GameOutcome视图控制器的override func viewDidLoad() { super.viewDidLoad() gameOutcomeLabel.text = boatMatchingGame.gameOutcomeText } 实例访问它,如下所示:

{{1}}