iOS 7上的反向箭头 [英] Back-like arrow on iOS 7

查看:135
本文介绍了iOS 7上的反向箭头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的应用程序中添加一个左侧栏按钮项,看起来像系统后退按钮,但不是系统后退按钮,因为它将出现在视图控制器上,这是我的navController堆栈的唯一vc并执行我自己的码。简单地写Back对我来说并不是很好,因为我需要显示<箭头也是。有没有办法以编程方式创建这样的箭头,而不用该箭头制作图像?

I need to add a left bar button item in my app that looks like system back button, but is not the system back button, since it will appear on view controller that is the only vc of my navController's stack and execute my own code. Simply writing "Back" isn't really good for me, as I need to display the "<" arrow as well. Is there a way to programmatically create an arrow like that, without making image with that arrow?

推荐答案

考虑使用虚拟 UIViewController 作为 UINavigationController 堆栈的根视图控制器:

Consider using a dummy UIViewController as a root view controller for your UINavigationController’s stack:

 [[UINavigationController alloc] initWithRootViewController:[UIViewController new]];
 [navController pushViewController:viewController animated:NO];

然后你可以使用我的 BackButtonHandler 扩展来处理后退按钮操作(如此主题):

Then you can use my BackButtonHandler extension to handle back button action (as described in this thread) :

 -(BOOL) navigationShouldPopOnBackButton {
      [self dismissModalViewControllerAnimated:YES];
      return NO; 
 }

这篇关于iOS 7上的反向箭头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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