[英]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.