Tag: uinavigationcontroller

UINavigationController和后退button操作

我有一个两个controllers第一个是self和第二个是maincontroller ,我在堆栈中的 maincontroller ,所以后退button自动到来。 这里我需要在用户按下后退button时发出警报。 我怎样才能做到这一点?

UINavigationController – 在所有视图中保留背景图像

可能重复: iOS 5中的UINavigationBar外观覆盖 有没有办法让导航控制器中的所有视图背景图像保持不变? 目前我在每个视图的viewDidLoad方法中加载相同的背景,但是这显示了从视图导航到视图时的背景图像移动。 我宁愿只是在背景的“幻灯片”视图infront的内容/closures屏幕,但背景保持静止。 这是我目前的背景图片加载代码: UIImageView *background = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)]; background.image = [UIImage imageNamed:@"InfoBackground.png"]; [self.view addSubview:background]; [self.view sendSubviewToBack:background]; [background release]; 谢谢!

如何从navigationController(viewControllers / stack)popup来指定viewController?

我已经创build了一个串行视图(A,B,C,D,…)的应用程序,我需要popupD到B.有人可能会说为什么不使用: [self.navigationController popToViewController:[[self.navigationController viewControllers] objectAtIndex:1] animated:YES]; 但是,这不是一个好的解决scheme。 因为这个方法需要你得到我们的“B”存储的索引。 问题 :如何获取viewControllers中的“B”的索引? UIViewControllers格式应该是: “<A:0x6e70710>”,“<C:0x6e30370>”,“<B:0x6988a70>”,“<D:0x6ea8950>”,“<E:0x6eaaad0>” 我试过了,没有使用rangeOfString和hasPrefix来获取“B”视图的索引。

为什么这个代码使用presentModalViewController? (不是pushViewController)

任何人都明白为什么在CoreDataBooks示例代码中: (a)控制器交换差异的方法 虽然点击一个项目,并进入详细视图使用什么似乎是标准的“ pushViewController ”UINavigationController概念,当你点击“添加”一个新的loggingbutton时,它启动新的视图,通过“ presentModalViewController “方法? 也就是说,在两种情况下,都不能使用pushViewController方法吗? 每种方法在使用方法上有没有什么优势? 我看不清楚。 我猜想苹果公司一定会为不同的场景select不同的方法。 例如: 他们会看到的任何用户差异(即UI差异或function差异)? 开发商的任何差异(或优点/缺点) 例如,如果您要考虑使用pushViewController方法而不是用于“添加”scheme的presentModalViewController方法… (二)数据共享方式差异 他们如何共享共同的数据对象的方法似乎是不同的 – 所以再次只是想知道为什么这些方法是不一样的? (即在这两种情况下,主控制器都暂时传递给另一个视图,并且它们之间有一些共享的数据 – 即子视图需要传递回父视图) 代码提取方便 这是“编辑”: – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Create and push a detail view controller. DetailViewController *detailViewController = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped]; Book *selectedBook = (Book *)[[self fetchedResultsController] objectAtIndexPath:indexPath]; // Pass the selected […]

如何“合法”淡出应用程序中的导航栏?

似乎只有通过向上滑动才能删除带有animation的导航栏。 我希望它褪色,就像在Photos.app。 苹果公司的指导原则规定 : 在iOS v5.0之前,当与导航控制器一起使用时,您可以对导航栏进行less量直接定制。 具体来说,可以修改barStyle,tintColor和semilucent属性,但是不能直接直接更改UIView级别的属性,如框架,边界,alpha或隐藏属性。 这个语言有点奇怪,因为它在iOS 5之前,但它表示你不能直接更改alpha值,它从来没有说你现在被允许。 我不希望我的应用程序被拒绝。 如何淡出导航栏就像我的状态栏?

基于不同的ViewController在iOS 7中设置灯光状态栏文字颜色的正确方法

我需要让一个特定的ViewControllerembedded在UINavigationController使其状态栏的文字颜色为淡(但其他ViewController的行为不同)。 我知道至less有3种方法,但其中没有一种适用于我的情况。 如何在iOS 7中更改状态栏的文字颜色 ,方法主要是: 在plist中将UIViewControllerBasedStatusBarAppearance设置为YES 在viewDidLoad中做一个[self setNeedsStatusBarAppearanceUpdate]; 添加以下方法: – (UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; } 运行在iOS 7.0.3上,这个方法对我来说不起作用,因为即使我正确实现了所有3个步骤, preferredStatusBarStyle也不会被调用。 UIStatusBarStyle PreferredStatusBarStyle不适用于iOS 7 ,该方法主要是: 将你的navigationBar的barStyle设置为UIBarStyleBlackTranslucent会给出白色的状态栏文本(即UIStatusBarStyleLightContent ),而UIBarStyleDefault会给出黑色的状态栏文本(即UIStatusBarStyleDefault )。 这个方法在iPhone上公平地工作,而不是在iPad上。 在plist中将UIViewControllerBasedStatusBarAppearance设置为NO ,然后使用 [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 这显然不适用于这种情况,因为我只需要为两个ViewController指定不同的状态栏颜色。 感谢所有的帮助!

在UINavigationBar左边的“返回”button旁边添加另一个button

我试了几个小时,但仍然无法解决。 当使用UINavigationController并在顶部推一个新的视图控制器时,我在导航栏的左侧有一个空闲的“后退”button。 我想要旁边的另一个button(显示popup式菜单)。 我想知道做什么是正确的方法。 或者我必须隐藏免费的后退button,并自己做一个相同的? 如果是这样的话,我也需要按下我自己的后退buttonpopup当前的视图控制器,对吧? 谢谢你的帮助。

如何在没有导航控制器的情况下将导航栏添加到视图

大家好我在我的应用程序,我有一个侧面菜单滑出来显示一个表格视图和forms在那里我有使用揭示视图控制器segues。 segue必须直接连接到视图控制器,否则应用程序崩溃,所以我不能使用导航控制器。 我的问题是如何添加一个没有导航控制器的酒吧button项导航栏。 我在故事板上完成了所有的布局。

对<UINavigationController:0xa98e050>开始/结束外观转换的不平衡调用

编译我得到的代码 “ <UINavigationController: 0xa98e050>开始/结束外观转换的不平衡调用” 警告。 这是我的代码 KVPasscodeViewController *passcodeController = [[KVPasscodeViewController alloc] init]; passcodeController.delegate = self; UINavigationController *passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:passcodeController]; [(UIViewController *)self.delegate presentModalViewController:passcodeNavigationController animated:YES];

Swift自定义后退button和目的地

我目前使用SWRevealViewController在我的应用程序中的侧边栏菜单。 当我单击其中一个选项时,目标视图控制器没有“返回”button,因为它不是来自正确的视图控制器(即返回的页面)。 因此,我想在目标视图控制器上手动创build一个返回button,这将返回到主视图控制器。 我已经看过这里的代码: 如何在iOS应用程序中手动设置“返回”目的地 但我正在努力在Swift中实现这个(一个接一个的错误!)。 任何帮助? 谢谢! 编辑 我已经尝试了下面的build议,但后退button只是不出现。 这可能有一些事实,我有隐藏在其他视图中的navbar,并在目标视图上执行以下操作: override func viewDidLoad() { super.viewDidLoad() navigationController.setNavigationBarHidden(false, animated:true) var myBackButton:UIButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton myBackButton.addTarget(self, action: "popToRoot:", forControlEvents: UIControlEvents.TouchUpInside) var myCustomBackButtonItem:UIBarButtonItem = UIBarButtonItem(customView: myBackButton) self.navigationItem.leftBarButtonItem = myCustomBackButtonItem } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } func popToRoot(sender:UIBarButtonItem){ self.navigationController.popToRootViewControllerAnimated(true) } 不知道为什么后退button不会显示? 编辑 这是从我的侧边栏视图控制器prepareForSegue。 如果有方法来检查segue标识符“testing”,那么我可以从这里设置后退button? – (void) prepareForSegue: […]