Question

I'm very new to storyboards and objective-c in general. Basically, I have a welcome screen with 4 buttons on it. Each button loads a new scene via the modal way. One of the screens requires an internet connection. I have already setup the function to check to see if there is internet. If there is no connection, I'd like it to load a separate scene. It looks like this (webView is the name of my UIWebView):

-(void)webView:(UIWebView *)myWebView didFailLoadWithError:(NSError *)error {
//code
}

Now, the only issue I'm having is how to load the scene that it should direct to in this function. I have the feeling that I need to start by creating an outlet for this specific scene, but I'm unsure of how to even do that. I tried searching for a guide on how to do it, but it is all going over my head since I'm so new to programming. Any help is greatly appreciated!

Was it helpful?

Solution 2

If you are talking about UIViewController when you are saying scene the there is a rely easy way to do it, just call the following in your desired method (off course with the required name changes)

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"YourStoryboardName" bundle:nil];
YourViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"YourViewControllerIdentifier"];

Now make sure that your storyboard has a UIViewController of type YourViewController and that UIViewController has YourViewControllerIdentifier as identifier set in the storyboard.

Now if you are talking about a custom UIView when you are saying scene then you can't do that, you can't load a custom UIView from a sotryboard without loading the proper view controller. But you can create a custom UIView with a .xib file and load it on your desired methods.

OTHER TIPS

1.) Set your project to use your storyboard inside of the project target's settings

2.) Inside storyboard, set which scene/class you want to load first by checking off the "Is Initial View Controller" property.

3.) Set up and segue through whatever other scenes/classes you have set up first

4.) Then when you reach the scene in question, have two different segues set up inside of your storyboard: one for if there's an internet connection and one if there isn't

5.) Check that condition and call performSegueWithIdentifier: and pass in the identifier that fulfills the internet connection critieria

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top