【发布时间】:2017-05-24 05:41:11
【问题描述】:
我制作了一个简单的应用程序,将 uibutton 添加到 collectionviewcell,但是当我执行操作时发生错误。这是一个屏幕截图。
和我的类代码:UIbutton {}
import Foundation
import UIKit
class KeypadUIButton: UIButton {
var qIndex : NSIndexPath?
}
我的单元格是:
import UIKit
class ConverterCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var keypadButton: KeypadUIButton!
}
和错误:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = padCollectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! ConverterCollectionViewCell
let index = indexPath.row
// -> cell.keypadButton.qIndex = indexPath as NSIndexPath
return cell
}
我的错误在哪里。你能帮助我吗 ?
【问题讨论】:
-
您的
keypadButton插座未连接。 -
在您的 stroyboard 中,您是否将按钮类设置为
KeypadUIButton??
标签: swift xcode uibutton collectionview