我正在使用一个下拉菜单帮助过滤数组,然后将数组中的数据放回collectionView中,但是,当我尝试运行应排序并重新加载collectionView的函数时,屏幕变为空白。 / p>
我尝试设置基线,然后过滤数组。
extension RestaurantDetails: menuViewDelegate {
func didChangeMealSize(mealSizeText: String) {
self.mealSize = mealSizeText
print("Usage", self.mealSize)
}
func didChangeDrink(drinkName: String) {
self.drink = drinkName
print("drink", self.drink)
}
func didChangeProductType(productType: String) {
self.productFilter = productType
print("Filter", self.productFilter)
}
func didchangeSwitch(FriesSwitch: UISwitch) {
if FriesSwitch.isOn == true {
self.FriesOnly = true
print("FRIES Only")
} else {
self.FriesOnly = false
print("Drink & FRIES")
}
func didendSelection(button: UIButton) {
print("ran Here")
if (SegmentType == "All" && FriesSwitch == false && mealSize == RestaurantDetails.allProductIdentifier && productFilter == RestaurantDetails.allProductIdentifier && price == 0.0) {
filteredProducts = products
} else {
filteredProducts = products.filter { ($0.usage?.lowercased() ?? "") == bestFor}
}
productCollection.reloadData()
}
我要按以下各项进行过滤:餐食大小,饮料和有无薯条。运行didendSelection时,将打印所选变量的所有属性,但是collectionView返回为空。