【发布时间】:2018-01-11 06:55:05
【问题描述】:
我有三个不同的字符串数组:
var firstArrayString: [String] = ["01:00", "02:00", "03:00"]
var secondArrayString: [String] = ["04:00", "05:00", "06:00"]
var thirdArrayString: [String] = ["07:00", "08:00", "09:00", "10:00"]
每个字符串数组都有价格:
var priceFirst: Int = 1000
var priceSecond: Int = 1500
var priceThird: Int = 2000
我使用 collectionCell 来显示我所有的数组字符串。
override func viewDidLoad() {
super.viewDidLoad()
var allArrayStrings: [String] = firstArrayString + secondArrayString + thirdArrayString
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return allTimeintervalArray.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "timeCell", for: indexPath) as! BookingTimeCell
cell.timeLabel.text = allTimeintervalArray[indexPath.item]
// how can I display different prices in each of the rows of the array?
}
我想在我的collectionCell中显示大致如此:
01:00 - 1000
02:00 - 1000
03:00 - 1000
04:00 - 1500
05:00 - 1500
06:00 - 1500
07:00 - 2000
08:00 - 2000
09:00 - 2000
10:00 - 2000
如何展示?
我尝试了很多 if 和 switch 的组合,但没有任何帮助,也许我写错了。请帮帮我。
【问题讨论】:
-
这是你的 allTimeintervalArray ???
标签: ios arrays swift string collections