线程1:EXC_BAD_INSTRUCTION(代码= EXC_I386_INVOP,子代码= 0x0

时间:2017-10-13 18:53:24

标签: swift xcode swift4

我在我的项目中使用下面的代码。更新到swift 4并运行我的应用程序崩溃后。我该如何解决?

代码:

    $array = [[0] => Array (
        [Advertisement and Printing] => 6
        )
    [1] => Array (
        [Advertising Agencies] => 7
        )
    [2] => Array (
        [Advertising Materials] => 8
        )
    [3] => Array (
        [Airport Ads] => 9
        )]
    ...

}

  

主题1:EXC_BAD_INSTRUCTION(代码= EXC_I386_INVOP,子代码= 0x0)

1 个答案:

答案 0 :(得分:0)

 // add to toolbar and render it
    let bar = UIToolbar()
    bar.setItems([tempItem],
                 animated: false)
    bar.snapshotView(afterScreenUpdates: true)

    //got image from real uibutton
    let itemView = tempItem.value(forKey: "view") as! UIView
    for view in itemView.subviews {
        if let button = view as? UIButton,
            let image = button.imageView?.image {
            return image.withRenderingMode(.alwaysTemplate)
        }
    }

    return nil
  }
}