-3
我來到這裏這樣的錯誤:導航欄圖片
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
什麼是錯我的代碼?我嘗試將圖像添加到navcontroller,我可以在這裏看到圖像。
func addNavBarImage() {
let nc = navigationController!
let image = UIImage(named: "2.png")
let imageView = UIImageView(image: image)
let bwidth = nc.navigationBar.frame.size.width
let bheight = nc.navigationBar.frame.size.height
let bannerx = bwidth/2 - (image?.size.width)!/2
let bannery = bheight/2 - (image?.size.height)!/2
imageView.frame = CGRect(x: bannerx, y: bannery, width: bwidth, height: bheight)
imageView.contentMode = .scaleAspectFit
navigationItem.titleView = imageView
}
究竟哪一行導致錯誤? – rmaddy