码迷,mamicode.com
首页 > 其他好文 > 详细

scenes & segues within storyboards

时间:2014-07-28 14:39:43      阅读:334      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   os   strong   io   for   

Scenes

Scenes in a storyboard represent content shown within one screen in your application. A scene involves a view controller and the views that make up its interface.

 

There’s also no limit as to how many scenes you can have within one storyboard.

If you have many scenes that are
part of a distinctly different part of your application, you could also separate them out
into another storyboard file.

Separate storyboards can be loaded programmatically.

eg, if you had a storyboard file named OtherStoryboard.storyboard, you
could load it by using the following command:

UIStoryboard *newStoryboard = [UIStoryboard storyboardWithName:@"OtherStoryboard" bundle:nil];

 

Segues

Segues allow you to easily transition from scene to scene. Segues are represented by
the UIStoryboardSegue class.

There are a few built-in segues that you can choose from. When working with an
iPhone application you can choose from push, modal, or custom. For the iPad you’re
given an extra choice of using a popover segue.

 

Modal segues slide a scene from the bottom to the top and appear to be on top
of the parent scene. You used a modal segue when showing your scene to create a
new task.

Push segues are used to transition the new scene in from the right. In
a push segue the original scene that prompted the segue then goes away by sliding
out to the left. You used this type of segue when tapping on a task from the tasks list
to show the task view.
Popover segues overlay only part of the parent view within a popover.
You can create custom segues by creating your own UIStoryboardSegue class. This
gives you full control over the transition and appearance of the new scene.


You create segues in your storyboard by using your mouse to drag a connection
from one scene or an actionable object to another.

 

// trigger it when a row in your table view was selected
-(void) tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"taskSegue"
      sender:self.tasks[indexPath.row]];
}
    

 

Passing data between view controllers with segues

Segues also allow you to pass data to the next view controller before completing the
transition. You do this by overriding the prepareForSegue:sender: method from
the originating view controller:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    UIViewController *destination = segue.destinationViewController;
    // Check to see if you’re preparing for the correct segue
    if ([segue.identifier isEqualToString:@"taskSegue"])
        // Setting the sender as the task property
        [destination setValue:sender forKeyPath:@"task"];
    else
        // Get destination controller if not taskSegue
        destination = [segue.destinationViewController topViewController];

// Set your current view controller as the delegate property [destination setValue:self forKeyPath:@"delegate"]; }

 

Problems with using storyboarding

1) multiple team members development

The biggest problem with storyboarding is that it’s extremely difficult to use when
working with a team that uses source code revision and management tools like Git,
Subversion, or Mercurial.

When multiple teammates make changes to the same storyboard,
it becomes problematic. Source code revision tools won’t be able to properly merge
the changes, and Xcode won’t be able to open the storyboard file until the changes
have been merged successfully. You’ll be forced to do a deep dive into the XML to fix
it yourself.

2) Another problem is that it forces older developers, who have been comfortable
using NIBs and creating and managing views programmatically, to change their
ways.

 

scenes & segues within storyboards,布布扣,bubuko.com

scenes & segues within storyboards

标签:des   style   blog   color   os   strong   io   for   

原文地址:http://www.cnblogs.com/davidgu/p/3872630.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!