从另一个 UIViewController 执行 Segue
Perform Segue from another UIViewController
我在主视图中使用 SWRevealViewController 库作为侧边菜单。我正在尝试从主视图(带有导航栏的视图我想传递到下一个视图)而不是在后视图(带有菜单 table 的视图)上执行 segue,所以我尝试使用该视图控制器而不是 'self' 执行 segue。但是,我收到一条错误消息,指出带有标识符的 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)
}
}
有人可以告诉我该怎么做吗?
谢谢。
不要忘记从 StoryBoard 设置标识符:
//objc code
SettingsController *view = [[SettingsController alloc] init];
view.blahBlah = self.blah;
[self.navigationController pushViewController:view animated:YES];
我也在使用 SwRevealViewController。这种安排将有助于获得所需的行为。检查您是否在 mainView 中缺少导航控制器(您如何设置 main viewcontroller。我认为您犯了错误)这就是您无法导航的原因。
问我你还有什么其他的queries.Hope这对你有帮助。
我在主视图中使用 SWRevealViewController 库作为侧边菜单。我正在尝试从主视图(带有导航栏的视图我想传递到下一个视图)而不是在后视图(带有菜单 table 的视图)上执行 segue,所以我尝试使用该视图控制器而不是 'self' 执行 segue。但是,我收到一条错误消息,指出带有标识符的 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)
}
}
有人可以告诉我该怎么做吗?
谢谢。
不要忘记从 StoryBoard 设置标识符:
//objc code
SettingsController *view = [[SettingsController alloc] init];
view.blahBlah = self.blah;
[self.navigationController pushViewController:view animated:YES];
我也在使用 SwRevealViewController。这种安排将有助于获得所需的行为。检查您是否在 mainView 中缺少导航控制器(您如何设置 main viewcontroller。我认为您犯了错误)这就是您无法导航的原因。
问我你还有什么其他的queries.Hope这对你有帮助。