[問題] swift delegate傳值後顯示在label
我在一個viewcontroller裡面分成上下兩塊,
上面是一個UIView
下面是一個container view並且有另外用一個ViewControllerB去控制
我在要傳值得controller加入了以下代碼
protocol sendItemPriceDelegate {
func sendPrice(_ price:String)
}
並在class 下面宣告
var delegate:sendItemPriceDelegate?
然後在API回來的地方加入
self.delegate = ViewControllerB() as sendItemPriceDelegate
delegate?.sendPrice(price)
回到controllerB繼承delegate並實作方法
func sendPrice(_ price: String) {
print(price)
itemPriceLabel!.text = price <===無法顯示出來
}
在印出price的時候是有值的
值是有傳過來的
但是要將它放在Label顯示出來卻一直顯示不出來
請大大們解惑
感謝~~
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 219.70.218.213
※ 文章網址: https://www.ptt.cc/bbs/MacDev/M.1515415128.A.C07.html
推
01/08 20:45,
6年前
, 1F
01/08 20:45, 1F
→
01/08 20:45,
6年前
, 2F
01/08 20:45, 2F
推
01/08 22:41,
6年前
, 3F
01/08 22:41, 3F
推
01/09 09:40,
6年前
, 4F
01/09 09:40, 4F
→
01/09 09:40,
6年前
, 5F
01/09 09:40, 5F
→
01/09 11:38,
6年前
, 6F
01/09 11:38, 6F
→
01/09 11:38,
6年前
, 7F
01/09 11:38, 7F
推
01/09 12:51,
6年前
, 8F
01/09 12:51, 8F
→
01/09 12:51,
6年前
, 9F
01/09 12:51, 9F
→
01/09 13:13,
6年前
, 10F
01/09 13:13, 10F
推
01/09 13:31,
6年前
, 11F
01/09 13:31, 11F
→
01/09 13:31,
6年前
, 12F
01/09 13:31, 12F
→
01/09 13:31,
6年前
, 13F
01/09 13:31, 13F
→
01/09 14:31,
6年前
, 14F
01/09 14:31, 14F
→
01/09 14:33,
6年前
, 15F
01/09 14:33, 15F
→
01/09 14:45,
6年前
, 16F
01/09 14:45, 16F
→
01/09 14:46,
6年前
, 17F
01/09 14:46, 17F