第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Segue和Button以編程方式迅捷

Segue和Button以編程方式迅捷

慕哥9229398 2019-08-28 15:28:28
Segue和Button以編程方式迅捷我正在使用iCarousel,我必須創(chuàng)建自己的按鈕。我想將編程按鈕中的數(shù)據(jù)傳遞給另一個視圖,但我沒有segue標(biāo)識符,因為我以編程方式創(chuàng)建了按鈕。我不知道是否可以通過編程方式創(chuàng)建segue的標(biāo)識符。button.addTarget(self, action: #selector(buttonAction3), for: .touchUpInside)         button.setTitle("\(titulos[index])", for: .normal)         tempView.addSubview(button)         let myImage = UIImage(named: "modo4.png") as UIImage?         button.setImage(myImage, for: .normal)let viewController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "modo") as! Modo1ViewControllerself.present(viewController, animated: false, completion: nil)if segue.identifier == "" {         if let destination = segue.destination as? Modo1ViewController {             destination.nomb = nombres        }     }
查看完整描述

2 回答

?
一只萌萌小番薯

TA貢獻1795條經(jīng)驗 獲得超7個贊

創(chuàng)造seuge

分配標(biāo)識符

和你的按鈕目標(biāo)

 @IBAction func button_clicked(_ sender: UIButton) {
        self.performSegue(withIdentifier: "segueToNext", sender: self)
 }

 override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "segueToNext" {
        if let destination = segue.destination as? Modo1ViewController {
            destination.nomb = nombres // you can pass value to destination view controller
            // destination.nomb = arrayNombers[(sender as! UIButton).tag] // Using button Tag        }
    }
 }


查看完整回答
反對 回復(fù) 2019-08-28
?
不負(fù)相思意

TA貢獻1777條經(jīng)驗 獲得超10個贊

在您的情況下,如果您使用self.present并且您想要在視圖之間發(fā)送數(shù)據(jù)。試試這個:

let viewController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "modo") as! Modo1ViewControllerviewController.nomb = nombresself.present(viewController, animated: false, completion: nil)

我不知道如何設(shè)置segue的標(biāo)識符,但我認(rèn)為上面的代碼可以提供幫助

如果您想更輕松地工作,可以在IB(Interface Builder)中創(chuàng)建segue并設(shè)置它的標(biāo)識符,然后使用

performSegue:withIdentifier:sender


查看完整回答
反對 回復(fù) 2019-08-28
  • 2 回答
  • 0 關(guān)注
  • 497 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號