Segue from one storyboard to a different storyboard?
Solution 1
I tried everything I had read but still had no success. I've managed to get it working using Rob Browns Storyboard Link It's easy to implement and works really fast
Solution 2
With Xcode 7 you can pick Storyboard References
and set the destination storyboard and controller
Solution 3
In Swift (iOS 8.1) this is pretty easy:
var storyboard: UIStoryboard = UIStoryboard(name: "Another", bundle: nil)
var vc = storyboard.instantiateViewControllerWithIdentifier("NextViewController") as AnotherViewController
self.showViewController(vc, sender: self)
Update for Swift 3:
let storyboard: UIStoryboard = UIStoryboard(name: "Another", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "NextViewController") as! AnotherViewController
self.show(vc, sender: self)
Solution 4
Adding a Reference to Another Storyboard - Apple developer doc
Solution 5
Another solution using segues (iOS SDK 6.0+), which keeps code separated by purpose and leaves room for customisation:
- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
//check/validate/abort segue
return YES;
}//optional
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
//sender - segue/destination related preparations/data transfer
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *destination = [[UIStoryboard storyboardWithName:@"SomeStoryboard" bundle:nil] instantiateInitialViewController];
UIStoryboardSegue *segue = [UIStoryboardSegue segueWithIdentifier:@"identifier" source:self destination:destination performHandler:^(void) {
//view transition/animation
[self.navigationController pushViewController:destination animated:YES];
}];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
[self shouldPerformSegueWithIdentifier:segue.identifier sender:cell];//optional
[self prepareForSegue:segue sender:cell];
[segue perform];
}
Note: UITableViewCell *cell
is used as sender
to keep default TableViewController
response behaviour.
BrownEye
Updated on August 22, 2020Comments
-
BrownEye over 3 years
I have too many views on one storyboard which is causing it to run really slow. I have been told that a solution to this issue would be to split the one storyboard into multiple storyboards. Could anyone tell me how I can segue from a view on storyboard 1 to a view in storyboard 2 via a button?