影响UINavigationBar的“后退按钮"方法(iOS) [英] Affecting a UINavigationBar's Back Button Method (iOS)

查看:74
本文介绍了影响UINavigationBar的“后退按钮"方法(iOS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个推到详细视图控制器的表格视图.从详细视图控制器中,当我按下后退"按钮时,我希望更改一个整数值.如何以编程方式编辑导航栏后退按钮的操作.后退按钮会自动放置在我的应用程序中,因为我使用的是表格视图,因此实际上并未创建该按钮,因此我不知道如何影响它的方法.

为清楚起见,我仍然希望后退按钮返回到原始视图,但同时更改一个整数的值.谢谢!

解决方案

我已经找到了一个简单的解决方法.我只是在包含UI的UINavigationController的界面生成器中取消选中显示导航栏".然后使用UINavigationBar来复制外观(但是我可以根据需要添加和删除按钮).

之后,我创建了IBAction,将其连接到按钮并可以从那里控制整数值.

(PS唯一的问题是,XCode界面构建器中没有向左指向箭头形状的后退"按钮,正如您所知道的那样.围绕此问题的解决方案很容易找到,如果您进行搜索)./p>

I have a table view that pushes to a detail view controller. From the detail view controller, when I press the 'back' button, I'd like an integer value to change. How do I edit the navigation bar back button's action programatically. The back button is automatically placed in my app because I'm using a table view so I didn't actually create the button, so I don't know how to affect it's method.

To be clear, I still want the back button to go back to the original view, but simultaneously change an integer's value. Thanks!

解决方案

I've figured out an easy fix to this. I simply unchecked 'Shows Navigation Bar' in the Interface Builder for the UINavigationController that the Table View was contained in. Then I used a UINavigationBar to replicate the look (but be able to add and delete buttons as I pleased).

After that I just created IBAction's that I connected to the buttons and could control an integer value from there.

(P.S. The only problem with this is that there is no 'Back' button left pointing arrow shape in the XCode interface builder as many of you know. There are solutions around this that are pretty easily found if you search).

这篇关于影响UINavigationBar的“后退按钮"方法(iOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆