简体   繁体   中英

Xib Vs Storyboard, how to update

I was studying Storyboard on the new iOS 5.0. It seems really simple to use and to implement but my question is... How can I update the old Xib to Storyboard?

For instance. I have some classes I developed when there was no storyboard and some of this classes come with xib file that help me to setup a custom layout quickly. Obviously when I use this kind of class I need to instantiate it using initWithNibName:bundle: and it now is ready to use and I can use it as many times I need because layout is coded inside xib.

Now Storyboard... Storyboard doesn't allow to load view controller from xib and I did not found a way to load storyboard file inside the main storyboard. It seems like I need to reconfigure layout for a particular view controller every time I use it in a new project. It seems that now I'm forced to reconfigure the layout of my controller in every new application that use this controller instead of using xib file that have the layout inside.

Maybe there is something I did not understand. Anyone can help me to understand the best way to use storyboard?

Thank you in advance.

Gabriele.

EDIT in reply to sw3n

Maybe I understood thanks to sw3n. This code below works but is this completely correct?

// All this code is implemented inside the MyViewController class.

// Attached to an UIButton;
- (void)loadNewController:(id)sender {
    [self performSegueWithIdentifier:@"newControllerIdentifier" sender:sender];
}

- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
    // As suggested by sw3n
    // Load the storyboard from file.
    UIStoryboard *storyboardTest = [UIStoryboard storyboardWithName:@"StoryBoardLoad_Test" bundle:nil];
    // Instantiate the viewController that live in the storyboard file
    UIViewController *destinationViewController = [storyboardTest instantiateViewControllerWithIdentifier:@"newControllerIdentifier"];
    
    // Instantiate a segue to start the chain
    UIStoryboardSegue *segue = [[UIStoryboardSegue alloc] initWithIdentifier:identifier source:self destination:destinationViewController];
    [self prepareForSegue:segue sender:sender];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"newControllerIdentifier"]) {
        [segue.destinationViewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
        
        // Are there new options to present the controller?
        // If I was in a NavigationController a could obviously push it.
        [self presentModalViewController:segue.destinationViewController animated:YES];
    }
}

这是您要找的东西吗?

(UIStoryboard *)storyboardWithName:(NSString *)name bundle:(NSBundle *)storyboardBundleOrNil

Sound a bit late to answer, but seem to have no conclusion to the answer. You can use storyboardWithName() that Nightfirecat mentioned above. Create the new Viewcontroller from UIStoryboard, and hook the new ViewController to where you want in the view hierarchy. You can use multiple storyboard files to segment your UX design this way too. I wrote something about how to hook it as rootcontroller on my site, but it should work anywhere basically.

Whenever you're tasked with a new project, what's the first thing you do?

Surely, whether you're a UX designer, a manager, or a stakeholder in the project, your first step would almost always comprise the ideation phase.

But while most companies will follow through with the ideation process, there's one very important step they'll often skip – and in my opinion, it's definitely NOT something to miss out on if you want to get a clear direction for the project right at the beginning.

I'm talking about storyboarding for user experience design, and in this article, you'll learn exactly what a UX storyboard is, how to build one, and why it is essential to create a logical story that has:

a strong plot a structured narrative a focus on the main goal you're trying to achieve What is Storyboarding in UX Design? A storyboard is a powerful visual communications tool to improve user stories by making them more authentic, emotional, simple, and clear. The underlying philosophy being that visual representations offer a far easier way to see elements making up the “big picture” than a text-based document.

First used in the early 1930s by filmmakers and animators at Walt Disney, a visual storyboard served as a means to graphically represent scenarios that contain a sequence of a few events. In UX design, storyboards are therefore a natural fit when it comes to representations of user interfaces, user events, new features, etc.

One of the first storyboards used by Walt Disney in the 1930s

Source: Disneyparks.disney.go.com

Storytelling and Storyboarding in UX Design A UX storyboard helps strengthen your research phase by exploring and visually predicting the user experience and interaction with a product over time, giving designers a clear sense of the user's priorities and goals even before the product or service is launched.

Storyboarding is a quick way to demonstrate how someone might interact with a future service or product. Through visual storytelling, you can easily set the ground for the whole team to come together and quickly grasp the essential aspects of the project – like the target audience, the occasion, and the goal.

Interface Builder:

  1. select the segue in your view controller
  2. go to the attributes tab
  3. give the segue a name
  4. set the transition style

In code:

[self performSegueWithIdentifier:@"mySegueNameFromInterfaceBuilder" sender:self];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM