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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

選擇UITableViewCell時(shí)如何進(jìn)行推送選擇

選擇UITableViewCell時(shí)如何進(jìn)行推送選擇

慕慕森 2019-11-11 12:55:38
我在表格視圖中有一個(gè)效果列表。我創(chuàng)建了一個(gè)右上方的按鈕,可以將按鈕推送到另一個(gè)視圖控制器,這有助于創(chuàng)建新的效果?,F(xiàn)在,我想向表視圖單元格添加推式序列,以便可以將效果值加載到添加效果視圖控制器上,并且可以保存編輯后的值。問(wèn)題是我可以以編程方式創(chuàng)建推送搜索嗎?如果不能,我可以通過(guò)prepareforsegue嗎?如果嘗試使用prepareforsegue,則會(huì)遇到一個(gè)問(wèn)題,即從中拖動(dòng)控件UITableView無(wú)法使我創(chuàng)建到添加效果視圖控制器的推送按鈕。
查看完整描述

3 回答

?
翻翻過(guò)去那場(chǎng)雪

TA貢獻(xiàn)2065條經(jīng)驗(yàn) 獲得超14個(gè)贊

control 從View Controller拖動(dòng)到View Controller


從View Controller到View Controlle!


您需要為您的segue提供一個(gè)標(biāo)識(shí)符:


執(zhí)行segue:


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

    [self performSegueWithIdentifier:@"yourSegue" sender:self];

}

現(xiàn)在這是事情,如果您需要將一些數(shù)據(jù)傳遞給該視圖控制器,它將僅執(zhí)行segue。然后,您必須實(shí)現(xiàn)以下segue委托:


- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

{

    // Make sure your segue name in storyboard is the same as this line

    if ([[segue identifier] isEqualToString:@"yourSegue"])

    {

        //if you need to pass data to the next controller do it here

    }

}


查看完整回答
反對(duì) 回復(fù) 2019-11-11
?
慕桂英546537

TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超10個(gè)贊

迅速

該答案顯示了如何傳遞數(shù)據(jù),并針對(duì)Xcode 8和Swift 3進(jìn)行了更新。


這是設(shè)置項(xiàng)目的方法。


使用創(chuàng)建一個(gè)項(xiàng)目TableView。請(qǐng)參閱此處的簡(jiǎn)單示例。

添加第二個(gè)ViewController。

從具有表格視圖的第一視圖控制器到第二視圖控制器的控制拖動(dòng)。選擇“顯示”作為segue類(lèi)型。

單擊情節(jié)提要中的segue,然后在“屬性檢查器”中,將標(biāo)識(shí)符命名為“ yourSegue”。(您可以隨意調(diào)用它,但還需要在代碼中使用相同的名稱(chēng)。)

(可選)您可以通過(guò)在情節(jié)提要中選擇第一個(gè)視圖控制器,然后轉(zhuǎn)到編輯器>嵌入>導(dǎo)航控制器,將所有內(nèi)容嵌入到導(dǎo)航控制器中。

具有TableView的First View控制器:


import UIKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {


    // ...



    // method to run when table view cell is tapped

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {


        // Segue to the second view controller

        self.performSegue(withIdentifier: "yourSegue", sender: self)

    }


    // This function is called before the segue

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {


        // get a reference to the second view controller

        let secondViewController = segue.destination as! SecondViewController


        // set a variable in the second view controller with the data to pass

        secondViewController.receivedData = "hello"

    }

}

第二視圖控制器


class SecondViewController: UIViewController {


    @IBOutlet weak var label: UILabel!


    // This variable will hold the data being passed from the First View Controller

    var receivedData = ""


    override func viewDidLoad() {

        super.viewDidLoad()


        print(receivedData)

    }

}

有關(guān)在視圖控制器之間傳遞數(shù)據(jù)的更基本的示例


查看完整回答
反對(duì) 回復(fù) 2019-11-11
?
白衣染霜花

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超10個(gè)贊

這是另一個(gè)選項(xiàng),不需要使用didSelectRowAtIndexPath。


您只需將Interface Builder中的序列從原型單元連接到目標(biāo)即可。


從那里您可以簡(jiǎn)單地:


override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

    if segue.identifier == "AffiliationDetail", let destination = segue.destinationViewController as? AffiliateDetailViewController {

        if let cell = sender as? UITableViewCell, let indexPath = tableView.indexPathForCell(cell) {

            var affiliation = affiliations[indexPath.row]

            destination.affiliation = affiliation

        }

    }

}


查看完整回答
反對(duì) 回復(fù) 2019-11-11
  • 3 回答
  • 0 關(guān)注
  • 550 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

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

公眾號(hào)

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