简体   繁体   English

从另一个UIViewController执行Segue

[英]Perform Segue from another UIViewController

I am using the SWRevealViewController library for a side menu within my main view. 我在主视图中的侧面菜单中使用了SWRevealViewController库。 I am trying to perform a segue from the main view (the one with the Nav Bar I want to be passed over to the next view) instead on the rear view (the one with the menu table), so I am trying to perform a segue using that view controller instead of 'self'. 我试图从主视图(带有导航栏的一个我想要传递到下一个视图)执行选择,而不是从后视图(带有菜单表的那个)执行选择,所以我试图执行一个使用该视图控制器而非“自己”进行搜索。 However, I am getting an error saying that the segue with identifier does not exist (it does). 但是,我收到一条错误消息,说带有标识符的segue不存在(确实存在)。

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

    switch indexPath.row {
    case 0:
        print("case 0")
        ViewController().goToView("to_playlist")
        break
    default:
        break
    }
}

class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UITableViewDataSource, UITableViewDelegate {
    func goToView(a: String) {
        performSegueWithIdentifier(a, sender: self)
    }
}

Can somebody please let me know how I can do this? 有人可以让我知道我该怎么做吗?

Thanks. 谢谢。

Don't forget to set identifier from the StoryBoard: 不要忘记从StoryBoard设置标识符:

//objc code
SettingsController *view = [[SettingsController alloc] init];
view.blahBlah = self.blah;
[self.navigationController pushViewController:view animated:YES];

am also using SwRevealViewController. 我也在使用SwRevealViewController。 This arraiangement will work to get the desired behaviour. 这种安排将有助于获得所需的行为。 check you are missing Navigation controller (How you are setting main viewcontroller. there you are making mistake i think) in the mainView thats why you are not able to navigate. 检查您是否在mainView中缺少导航控制器(如何设置主viewcontroller。我认为您在犯错误),这就是为什么您无法导航的原因。 在此处输入图片说明

ask me you have any other queries.Hope this will help you. 问我您还有其他疑问。希望这会对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UIViewController不会选择另一个UIViewController吗? - UIViewController will not segue to another UIViewController? 使用数组值Swift3从UITableViewController到UIViewController执行Segue - Perform Segue from UITableViewController to UIViewController with Array Value Swift3 在来自第三个UIViewController的两个UIViewController之间执行搜索 - Perform a segue between two UIViewControllers from third UIViewController 如何以编程方式从SKScene到UIViewController执行成功的搜索 - How to perform a successful segue programmatically from SKScene to UIViewController 从另一个视图执行 segue 作为全视图 - perform segue as full view from another view 从另一个类错误执行segue找不到segue - Perform segue from another class error can't find segue 从UIViewController选择到UITableViewController - segue from UIViewController to UITableViewController 从Xib中选择到UIViewController - Segue to UIViewController from a xib 如何以编程方式从一个UIViewController切换到另一个,而无需模态或Push? - How to programmatic segue from one UIViewController to another without Modal or Push? 从一个UIViewController推送到另一个UIViewController时发生SIGABRT错误 - SIGABRT error when pushing segue from one UIViewController to another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM