当我试图宣布
时,我收到错误消息 Thread1:EXC_BAD_INSTRUCTION(code = EXC_1386_INVOP,subcode = 0x0) var buttonFrame = customButton.frame
这是我的代码。任何帮助表示赞赏。
override func viewDidLoad() {
super.viewDidLoad()
//sends menuOverlay to back on load
parentView.sendSubviewToBack(menuOverlay)
self.menuOverlay.hidden = true
//sends sliderContainer back and makes its origin at the button
let containerFrame = sliderContainer.frame
let containerFrameX = containerFrame.minX
let containerFrameY = containerFrame.minY
var buttonFrame = customButtonOne.frame
let sliderOriginX = buttonFrame.minX + (buttonFrame.width / 2)
let containerTranslationX = CGFloat(containerFrameX-sliderOriginX)
let containerTranslationY = CGFloat(-containerFrameY)
self.sliderContainer.transform = CGAffineTransformMakeScale(0.001, 0.001)
self.sliderContainer.transform = CGAffineTransformMakeTranslation(containerTranslationX, containerTranslationY)
}
答案 0 :(得分:0)
如果customButtonOne
是未连接的IBOutlet,则为nil
。 nil
没有frame
属性,因此崩溃。
确保您的IBOutlet已连接。