原来在 Storyboard 上的 申购 tableViewCell,只有四个 UILabel,现在扩充第五个 UILabel,先将他命名为 fifthSectionLabel。这个 UILabel 装载的资讯,就是价差百分比。显示的格式如 11.22% 这样的格式。
先将 UILabel 在 storyboard 上拉好。
然後在 ViewController 中的 cellForRowAt(:) 中,呼叫 model,得到价差百分比 String。如果有得到 String,就显示在 fifthSectionLabel,如果 String 为 nil,则显示 -%
所以扩充後的 cellForRowAt 如下
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: StockSubscriptionTableViewCell.identifier, for: indexPath) as? StockSubscriptionTableViewCell,
let info = model.getSubscriptionInfo(at: indexPath) else {
return UITableViewCell()
}
let state = "申购状态"
let firstSection = "\(info.stockName) - (\(info.stockCode))"
let secondSection = "申购股数: \(info.stockCountString)"
let thirdSection = "申购价: \(info.actualPrice)"
let forthSection = "中签率: \(info.subscriptionRateString) %"
let fifthSection: String
if let percentageDiffString = model.getPricePercentDifferenctString(subscription: info) {
fifthSection = "价差: \(percentageDiffString) % "
} else {
fifthSection = "价差: -- % "
}
cell.stateLabel.text = state
cell.firstSectionLabel.text = firstSection
cell.secondSectionLabel.text = secondSection
cell.thirdSectionLabel.text = thirdSection
cell.forthSectionLabel.text = forthSection
cell.fifthSectionLabel.text = fifthSection
modify(cell, with: info)
return cell
}
完成後的 UI 就如下,就可以知道价差了。建议找价差百分比高的申购,如果真的抽中了,赚的机率比较高,因为申购不一定会赚。
台股申购日历
IT铁人赛Demo App
下方是这次 D1 ~ D12 的完成品,可以下载来试
App Store - 台股申购日历
这 30 天我们整理了许多 Python 的基本语法,包括了基本的输入输出、if 判断式、while...
架构图 简介 Node-RED是基於Node.js建构的web浏览器可视化模块开发工具,所以不需要熟...
大家好,我是长风青云。今天是铁人赛的29天。这是我最後一个要讲的演算法喔。 如果明天的部分不想看不想...
前言依旧被吃了~跟月饼一样(虽然明天才是中秋节XD) ▉前导观念~先理解这两个数值是怎麽评分的~ (...
国庆连假中,假日只想耍废玩 game,不想进修QQ,但为了避免断赛,还是加减推一些东西,等明後天再来...