如何以编程方式执行Unwind segue?
本文翻译自:How to perform Unwind segue programmatically?
Using storyboard this is very easy. 使用情节提要非常简单。 You just drag the action to "Exit". 您只需将动作拖到“退出”即可。 But how should I call it from my code? 但是如何从代码中调用它呢?
#1楼
参考:https://stackoom.com/question/qUGs/如何以编程方式执行Unwind-segue
#2楼
- Create a manual segue ( ctrl -drag from File's Owner to Exit), 创建一个手动序列(从文件所有者的ctrl -drag拖动到Exit),
- Choose it in the Left Controller Menu below green EXIT button. 在绿色EXIT按钮下方的左侧控制器菜单中选择它。
Insert Name of Segue to unwind. 插入“名称”以展开。
Then, - (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender.
然后, - (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender.
with your segue identify. 与您的segue标识。
#3楼
I used [self dismissViewControllerAnimated: YES completion: nil];
我用了[self dismissViewControllerAnimated: YES completion: nil];
which will return you to the calling ViewController
. 这将使您返回到调用ViewController
。
#4楼
FYI: In order for @Vadim's answer to work with a manual unwind seque action called from within a View Controller you must place the command: 仅供参考:为了使@Vadim的答案与在View Controller中调用的手动展开固定动作配合使用,必须放置以下命令:
[self performSegueWithIdentifier:(NSString*) identifier sender:(id) sender];
inside of the overriden class method viewDidAppear like so: 在覆盖的类方法viewDidAppear中,如下所示:
-(void) viewDidAppear:(BOOL) animated
{[super viewDidAppear: animated];[self performSegueWithIdentifier:@"SomeSegueIdentifier" sender:self];
}
If you put it in other ViewController methods like viewDidLoad or viewWillAppear it will be ignored. 如果将其放在其他ViewController方法(如viewDidLoad或viewWillAppear)中 ,它将被忽略。
#5楼
Quoting text from Apple's Technical Note on Unwind Segue: To add an unwind segue that will only be triggered programmatically, control+drag from the scene's view controller icon to its exit icon, then select an unwind action for the new segue from the popup menu. 引用Apple的Unwind Segue技术注释中的文本:要添加只能以编程方式触发的Unwind Segue,请按住Control键并将其从场景的视图控制器图标拖到其退出图标,然后从弹出菜单中为新的Segue选择一个Unwind操作。
Link to Technical Note 链接到技术说明
#6楼
Backwards compatible solution that will work for versions prior to ios6, for those interested: 向后兼容的解决方案将对那些感兴趣的人适用于ios6之前的版本:
- (void)unwindToViewControllerOfClass:(Class)vcClass animated:(BOOL)animated {for (int i=self.navigationController.viewControllers.count - 1; i >= 0; i--) {UIViewController *vc = [self.navigationController.viewControllers objectAtIndex:i];if ([vc isKindOfClass:vcClass]) {[self.navigationController popToViewController:vc animated:animated];return;}}
}
如何以编程方式执行Unwind segue?相关推荐
- Spark-sql:以编程方式执行Spark SQL查询(通过反射的方式推断出Schema,通过StrutType直接指定Schema)
1.编写Spark SQL查询语句 在这之前创建Maven项目.创建的过程如:http://blog.csdn.net/tototuzuoquan/article/details/74571374 在 ...
- java编译器jdk版本_以编程方式确定Java类的JDK编译版本
java编译器jdk版本 当需要确定使用哪个JDK版本来编译特定的Java .class文件时, 通常使用的方法是使用javap并在javap输出中查找列出的"主要版本". 我在我 ...
- 以编程方式确定Java类的JDK编译版本
当需要确定使用哪个JDK版本来编译特定的Java .class文件时, 通常使用的方法是使用javap并在javap输出中查找列出的"主要版本". 我在博客文章Autoboxing ...
- julia语言 调用 java_以编程方式/动态导入Julia中的模块
NOTE: 请参考用户1712368的(Jameson Nash,Julia dev)回答,这个discussion在julia-users邮件列表和Julia manual的这个条目中,要知道为什么 ...
- Java jdt 编辑_java – 如何使用JDT以编程方式重命名方法
我认为你最有希望的方法是去eclipse源代码. >使用源代码下载所需的版本.特别是,您需要JDT插件的源代码,它包含在"经典"版本中.以下所有内容均基于4.2.1. > ...
- 编程方式刷新Squid缓存服务器的五种方法
网站进行内容更新是常有的事情,当被缓存的资源更新时,前端Squid 缓存服务器内容也必须要相应的更新,否则用户就可能会看到过期的数据.当没有程序支持时就需要每次登录到服务器上执行刷新操作,在服务器数量 ...
- android 联系人编辑界面,android – 以编程方式编辑联系人的姓名/电话号码
我试图以编程方式修改联系人的显示名称: try { ArrayList ops = new ArrayList(); ops.add(ContentProviderOperation.newUpdat ...
- LINUX按照物理地址预取,linux – 如何以编程方式禁用硬件预取?
我想以编程方式禁用硬件预取. 这是一个相关的片段: "DPL Prefetch and L2 Streaming Prefetch settings can also be changed ...
- CodeFirst 的编程方式
CodeFirst 的编程方式 第一步:创建控制台项目 第二步:添加新建项目→Ado.Net空实体模型 第三步:添加实体:Customer,添加几个必要的测试字段 第四步:添加实体之间的联系 第五步: ...
最新文章
- 如何实现iframe(嵌入式帧)的自适应高度
- day16_ajax学习笔记
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderL,spring获取context...
- [CentOS] CentOS 使用yum安装 php,mysql, apache
- php在页面循环输出标签,自定义页面循环
- numpy(3)-numpy.random.random() ,random_sample()连续均匀分布
- HBase应用笔记:通过Java Api与HBase交互(转自 Taobao QA Team)
- {面试题49} 把字符串转换成整数
- Product mass creation tool
- type const mysql_Mysql Explain之type详解
- python如何改变数据类型_如何改变numpy数组的数据类型和形状?
- 媒体服务器协议,媒体服务器介绍(mediactrl架构)
- MySQL裸机性能测试(2021)
- Databricks文档01----Azure Databricks初探
- 5G iPhone消息刺激?苹果股价3连涨市值已超过1.2万亿美元
- Javasctipt面试题整理
- axure 元件_Axure流程图制作
- [Unity]PureMVC框架解读(上)
- 设置vscode默认打开浏览器为谷歌
- javascript无限请求_SockJS - 重新连接后无限xhr-streaming呼叫
热门文章
- 部分win11打开应用商店出错的问题 0x80131500
- 微信小程序时间格式转换
- 微信小程序云开发 把时间戳转换成正常的时间格式上传到数据库中
- java获取pdf文件首页图片,用来当做封面
- IOS 最右 注册 登录协议分析记录
- passwd: Have exhausted maximum number of retries for servic、ssh用普通用户登录输入密码正确但是登录却提示被拒绝问题解决,su到root报错
- Binary_Search(二叉树搜索---------二分)
- 20230426作业
- VMware 常见问题集锦
- teamViewer远程连接vnp过程