【发布时间】:2016-04-17 12:38:43
【问题描述】:
我正在尝试使用iCarousel 来显示一系列项目。我想为此重用一个故事板 UIView,所以我创建了一个 UIView 的自定义类。我还为此创建了一个 XIB 文件,并根据自己的喜好设置了视图。然后,我将我的观点的出口连接到班级。我现在正在尝试重新创建 UIView,以便我可以将它用于我的轮播。这是我自定义的 UIView 类:
这是我的轮播代码:
func numberOfItemsInCarousel(carousel: iCarousel) -> Int {
return costs.count
}
func carousel(carousel: iCarousel, viewForItemAtIndex index: Int, reusingView view: UIView?) -> UIView {
let rView = ReturnView(frame: CGRectMake(0, 0, 220, 220))
rView.backgroundColor = UIColor.greenColor()
print(rView.deleteBtn)//fatal error: Unexpectedly found nil when unwrapping an optional value
return rView
}
从我的致命错误中可以看出,删除按钮不存在。这与我的其他元素相同。没有子视图出现:
如何让子视图出现在我的 iCarousel 上?感谢您的帮助。
【问题讨论】:
标签: ios iphone swift uiview icarousel