scenes & segues within storyboards

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

时间: 2024-10-13 22:26:04

scenes & segues within storyboards的相关文章

开始使用Storyboards

“你的应用程序可以完整的储存在一个文件中,并且IB自动构建成单独的分离文件去做最优化的加载.简而言之,你不必担心使用storyboards时的加载时间或者性能.” 实例化一个Storyboard 当你的‘UIMainStoryboardFile’已经设置好了,随着程序的启动窗口,编译器在自动生成代码时实例化Storyboard并且加载. 假如你已经添加了storyboards到你现有的APP中,你就开始编码吧.storyboard实例化view controllers的方法都定义在UIStory

关于storyboard的使用入门

 在iOS5以前,一直使用纯代码进行处理界面,尽管能够严格数据信息,但是操作上相比storyboards操作效率低,现就这个时尚的storyboards进行简要学习总结. 一  创建storyboards. 创建storyboards的方式有多种,比较常见的是在创建工程的时候就进行创建,另外也可以再创建完毕工程后在进行添加storyboards,这两种方式的创建效果都是一样的.创建好以后,可以再plist中找到UIMainStoryboardFile关键字.  二  实例化storyboar

转换到 StoryBoard 的发布说明(Converting to Storyboards Release Notes)

转换到 StoryBoard 的发布说明(Converting to Storyboards Release Notes) Storyboarding is a new way to create user interfaces for iOS applications, beginning with iOS 5 and Xcode 4.2. Using storyboards, you can design the view controllers that compose your appl

Storyboards vs NIB vs Code 大辩论

前言 做iOS开发的童鞋都应该会纠结一个问题,那就是在做开发的时候是使用StoryBoard还是使用Nibs又或者是Code(纯代码流)呢?笔者也非常纠结这个问题,今天碰巧在raywenderlich上面看到了几个大神之间的撕逼,哦不,讨论之后,感觉收获良多,于是就将他们讨论的内容整理翻译了一下,如有不当之处,还请多多包涵,原视频请戳这里 http://t.cn/zRAb4NF 讨论 Ray Wenderlich Ok!现在我们都在线,感谢各位的到来,今天我们会有一个讨论关于iOS开发的讨论,是

Storyboards Tutorial 02

Adding a Table View Controller 连接到tab bar controller中的两个窗口都是regular UIViewControllers.你将使用UITableViewController来替换第一个tab 选择第一个view controller然后delete它.拖一个table view controller. 选择table view controller,然后在xcode上方的菜单栏中选择Editor\Embed In\Navigation Contr

【Xamarin Doc】 Introduction to Storyboards 笔记

http://developer.xamarin.com/guides/ios/user_interface/introduction_to_storyboards/ Segues There are different types of transitions, each giving control over how a new View Controller is presented to the user and how it interacts with other View Cont

如何从项目中移除storyboards

我不想在超过4-5屏的项目中使用storyboards,当我新建一个项目时,我通常按照下面的步骤操作. 我不想谈论storyboards本身的问题,如果你对这个话题感兴趣,推荐读这篇文章. 在本文中我们将从Single View Application模板中移除storyboard,并使用导航栈来储存不限数量的视图控制器,然后模态化的显示视图页面. 创建新项目 创建一个新项目并选择Single View Application模板.将其命名为NoStoryboards并选择Swift作为编程语言

iOS Storyboard unwind segues使用小结

iOS Storyboard unwind segues使用小结 转载:http://blog.csdn.net/kid_devil/article/details/23218195 使用storyboard开发的时候,经常会在一个scene上添加一个button,再拖拽这个button到某个想要关联的页面,最后选择push的方式跳转.这样scene_A和scene_B就有了一个“顺序”的跳转方式了.但有时,希望可以从scene_B触发某个action,跳转回scene_A.如果还采用刚才的方式

自学ios:segues

action seques['segwei] 联线: 1) modal: slide a scene from the bottom to the top, covered on the parent scene. 2) push: slide from right to left. 3) custom 自学ios:segues,布布扣,bubuko.com