私は、以下の配列を使用して自分のtableViewを作成しています。ユーザーが配列を検索し、項目が見つかった場合、そのセルを選択する必要があります。私は以下の使用しています関数を使用してUITableViewCellを選択するには、タップする必要はありませんか?
(
{
barcode = 8901058847857;
image = (
);
name = "Maggi Hot Heads";
productTotal = "60.00";
quantity = 3;
},
{
barcode = 8901491101837;
image = (
);
name = "Lays Classic Salted";
productTotal = "20.00";
quantity = 1;
}
)
は、配列内のバーコードを検索するためのコードを述べたが、私は他のケースでtableViewCellを選択する方法、さらに進行するのか分かりません。 tableViewCell setSelectedに記述されたコードがあります。
let namePredicate = NSPredicate(format: "barcode contains[c] %@",code)
let filteredArray = orderDetailsArray.filter { namePredicate.evaluate(with: $0) }
if filteredArray.isEmpty {
let alert = UIAlertController(title: "Alert", message: "Item not found in cart.", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: { action in
self.scan()
}))
self.present(alert, animated: true, completion: nil)
}else{
print("item found")
// Need to do selection here
}
あなたは、単にあなたがウルマックを持っていたときにバーコードを濾過し、cellForRow –