首页 > 其他分享 >IOS: Unwind Segues

IOS: Unwind Segues

时间:2022-12-16 17:40:06浏览次数:59  
标签:Unwind segue unwind iOS IOS will Segues return method


原文: http://www.intertech.com/Blog/iOS-Unwind-Segues/

In iOS 5, we were introduced to Storyboards and Segues.  While these features simplified the navigation process in our apps, we weren’t given a way to define a return to previous modal scenes via Interface Builder.

You may have noticed that in iOS 6, a green icon has been added to the control bar of each scene in the Storyboard.

​​

This is a new, and surprisingly overlooked feature for iOS 6, which provides the missing “return” functionality.  It’s called an “unwind segue.”

The process is simple:

  • Add a private method inside each View Controller you wish to “unwind” to (a common mistake is to add this code into the View Controller you wish to unwind from).
  • This method includes one (and only one) parameter that’s a pointer to a UIStoryboardSegue, and a return type of IBAction .
  • The name of this method can be whatever you’d like.  However, all of the unwind segues will be listed in one place,so it’s a good idea to pick a descriptive naming pattern, such as unwindToRootVC.
  • There is no need to have anything in the body of this method.  The signature is what’s important.
  1: -(IBAction)unwindToRootVC:(UIStoryboardSegue *)segue
2: {
3: // Nothing needed here.
4: }



  • Inside your Storyboard, hold the control key down while dragging from your button (or other control) to the green exit icon below.

​​

  • You will see a list of every unwind segue available here… that’s why coming up with a consistent and descriptive naming pattern is important.

​​

That’s it!  You are now able to return to any previous scene simply by selecting the appropriate unwind segue.  Also, unlike following a ‘regular’ segue, this will use not create a new object for every request!

Read more: ​​http://www.intertech.com/Blog/ios-unwind-segues/#ixzz39OhH56Aj​​​ 
Follow us: ​​​@IntertechInc on Twitter​​​ | ​​Intertech on Facebook​


标签:Unwind,segue,unwind,iOS,IOS,will,Segues,return,method
From: https://blog.51cto.com/u_3457306/5947991

相关文章

  • Storyboards Tutorial in iOS 7: Part 2
    原文 http://www.raywenderlich.com/50310/storyboards-tutorial-in-ios-7-part-2NotefromRay:Ifyouwanttolearnaboutstoryboarding,you’vecometotherightp......
  • ios 开发中 注册并使用个性化URL Schema
    -(BOOL)openURL:(​​NSURL​​ *)url  AnobjectrepresentingaURL(UniversalResourceLocator).UIKitsupportsthehttp:,https:,tel:,andmailto:schemes.......
  • 给iOS工程增加Daily Build
    前言DailyBuild是一件非常有意义的事情,也是敏捷开发中关于“持续集成”的一个实践。DailyBuild对于开发来说有如下好处:保证了每次checkin的代码可用,不会造成整个工程编译......
  • 关于airtest群控制ios
    1.安装carthagebrewinstallcarthage2.下载项目gitclonehttps://github.com/facebookarchive/WebDriverAgent./Scripts/bootstrap.sh#如果报错多半是node版本......
  • uniapp开发的微信小程序页面在IOS上页面可被拖拽的问题
    经排查发现是设计稿宽度不是750px而IOS宽度最低都是375(750/2)这时如果你的设计稿是751px的在IOS上就可以被自由拖拽 解决方案:1让UI出750px的设计稿2设......
  • iOS 申请证书(开发与发布)(开发者帐号开通后)
    苹果开发者帐号开通后,即了购买服务后。苹果APP需要上架,也提供了新的开发者账号,所以就顺带把申请证书与发布流程写一遍。0.先创建苹果钥匙串文件(在苹果电脑PC(一体机、笔记本......
  • Linux命令iostat使用,输出的参数分析
    Linuxiostat命令编译iostat源码位于sysstat中,编译其会在bin目录下得到iostat可执行文件;iostat命令参数解析iostat命令输出解析iostat[-c][-d][-h][-N][......
  • iOS分享扩展支持自定义联系人
    iOS分享扩展支持自定义联系人iOS可以通过添加ShareExtension来扩展系统的分享组件,能够支持将网页,图片,音乐或任何接入了系统分享组件功能的应用分享到我们自己的App内。分享......
  • VUE使用axios数据请求时报错 TypeError Cannot set property 'xxxx' of undefined 的
    正常情况下在data里面都有做了定义data(){list:"haha"}在函数里面进行赋值this.list=response.data.result这时候你运行时会发现,数据可以请求到,但是会报错TypeErr......
  • iOS ui自动化测试mac环境部署
    整体框架基于:python3+WebDriverAgent+Facebook-wda+Weditor(待贴图)安装Homebrew工具:/usr/bin/ruby-e"(curl-fsSL https://raw.githubusercontent.com/Homebrew/......