1
我有一個UICollectionViewCell子類,它有一個UIStackView。 StackView填充了UIButtons,一切看起來都很好 但是這些按鈕是不可用的。iOS Swift 3 - UICollectionViewCell中的UIStackView上的UIButton沒有響應輕擊事件(無交互)
如果我佈局上UIScrollView同一按鈕(用於實驗的緣故),而不是在stackview,所以它看起來像是與stackview導致了問題
任何想法的按鈕罰款迴應?
下面是我如何將按鈕添加到StackView
func prepareStackView(buttonsArray: Array<UIButton>) {
var rect:CGRect = (stackView?.frame)!
rect.size.width = btn.frame.size.width * buttonsArray.count
stackView?.frame = rect //The frame of the stackview is set as such so that it looks exactly like I want
//Add all the buttons
for btn in buttonsArray {
//The buttons already have their selectors set
stackView?.addArrangedSubview(btn)
}
}
禁用stackview交互stackview.isUserInteractionEnabled =假 –
爲什麼?然後它的任何排列的視圖都無法互動 – Zigglzworth
我認爲stackview會覆蓋button的interactable屬性。那麼,我曾經說過,你試過了嗎? –