簡體   English   中英

在沒有Segue的情況下調用情節提要

[英]Call Storyboard without Segue

我試圖在不使用Segue的情況下推送ViewController,但是它不起作用。 我的按鈕代碼如下:

-(void)consultaButton
{
    NSString *storyboardName = @"Main";
    NSString *viewControllerID = @"Consultas";
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
    EntradaViewController *controller = (EntradaViewController *)[storyboard instantiateViewControllerWithIdentifier:viewControllerID];
    [self presentViewController:controller animated:YES completion:nil];
}

EntradaViewController / Entrada =原始ViewController ConsultasViewController / Consultas =目標ViewController

我有錯誤:

2013-12-12 14:42:51.519 JuntaComercial[14285:70b] -[EntradaViewController consultaButton:]: unrecognized selector sent to instance 0x9e51650

有人可以幫我嗎? 我已經在使用Segue並且工作正常,但是現在我需要在沒有Segue的情況下執行相同的操作。 感謝名單!


更新(工作代碼):

-(void)consultaButton:(id)sender
{
    NSString *storyboardName = @"Main";
    NSString *viewControllerID = @"Consultas";
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
    EntradaViewController *controller = (EntradaViewController *)[storyboard instantiateViewControllerWithIdentifier:viewControllerID];
    [controller setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
    [self presentViewController:controller animated:YES completion:nil];
}

這似乎與情節提要/ segue代碼無關。 而是,您有一個配置了操作的按鈕,並且已將操作設置為consultaButton:但是該方法實際上是consultaButton (請注意,由於該方法沒有參數,因此缺少冒號。因此,請更正方法簽名或您要設置為按鈕操作的選擇器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM