因此,我有一个“状态”单元格,该单元格可以告诉我某个项目是否已“列出”,“出售”或“已发货”。
可以同时列出,出售和运送任何特定物品,但我希望状态单元格的优先级像这样:(已卖出已列出)。
从其他可能包含或不包含数据的单元格中获取的每个发货,出售和列出的状态信息。
到目前为止,我将其作为公式:
=IF(AND($K4)<>"","Shipped",IF(AND($F4)<>"","Sold",IF(AND($H4)<>"","Listed")))
现在,我的一个单元格的“状态”为“已打包”,但是当我取出K4单元格中的数据(又名:出厂数据)时,它说有错误。如果我的函数正确,那么K4中的数据不足将使公式在F4中查找数据并继续使用以下IF函数。
我不知道我是否遗漏了一个微小的细节,或者是否做错了所有事情。任何帮助将不胜感激。
答案 0 :(得分:4)
不需要IF
-您只需要在嵌套的=IF($K4<>"","Shipped",IF($F4<>"","Sold",IF($H4<>"","Listed","")))
公式中运行逻辑即可
struct Content {
let name: String
let color: UIColor
init(name: String, color: UIColor) {
self.name = name
self.color = color
}
}
class CollecitonViewWithCollectionView: UIViewController {
let testContent = [Content(name: "AA", color: .red), Content(name: "BB", color: .green), Content(name: "CC", color: .yellow)]
@IBOutlet weak var collectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
collectionView.accessibilityContainerType = .landmark
}
}
extension CollecitonViewWithCollectionView: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1
}
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 10
}
func collectionView(_ collectionView: UICollectionView, canFocusItemAt indexPath: IndexPath) -> Bool {
return false
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CollectionViewCell", for: indexPath) as? CollectionViewCell else {
return UICollectionViewCell()
}
cell.content = testContent
return cell
}
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
guard let headerView = collectionView.dequeueReusableSupplementaryView(
ofKind: UICollectionElementKindSectionHeader,
withReuseIdentifier: "HeaderView",
for: indexPath
) as? HeaderView
else {
return UICollectionReusableView()
}
return headerView
}
}
extension CollecitonViewWithCollectionView: UICollectionViewDelegate {
}
class InnerCollectionTestCell: UICollectionViewCell {
@IBOutlet weak var testLabel: UILabel!
}
class CollectionViewCell: UICollectionViewCell, UICollectionViewDelegate, UICollectionViewDataSource {
@IBOutlet weak var collectionView: UICollectionView!
var content: [Content]?
override func awakeFromNib() {
super.awakeFromNib()
collectionView.dataSource = self
collectionView.delegate = self
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return content?.count ?? 0
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "InnerCollectionTestCell", for: indexPath) as? InnerCollectionTestCell else {
return UICollectionViewCell()
}
cell.testLabel.text = content?[indexPath.row].name ?? "Failed"
cell.backgroundColor = content?[indexPath.row].color ?? .black
return cell
}
}
class HeaderView: UICollectionReusableView {
@IBOutlet weak var titleLabel: UILabel!
}