Tag: uinavigationcontroller

UINavigationController不起作用

我正在使用一个UITabBar为我的应用程序,但(由于我自己的原因),我不得不删除它。 现在没有我的UINavigationControllers工作。 当我呼吁: [self.navigationController pushViewController:myViewController animated:YES]; 该代码现在什么都不做,因为我没有UINavigationController ,我不知道如何做一个将工作。

如何为ABPersonViewController的导航栏添加一个返回button?

当我显示一个ABPersonViewController ,我需要一个允许我closures它并返回到前一个屏幕的button。 我如何添加这个?

UITabBarController / UINavigationController旋转问题

我的问题是以下几点:我只想允许所有ViewController的纵向方向,除了1个ViewController,它应该允许纵向和横向左/右。 现在我已经花费了将近2天的时间来为iOS设置不同的幻灯片/ ViewController的方向。 经过一番search,我发现这个线程在堆栈: UITabBarController旋转问题在iOS 6 我遵循了Kunani在这个主题中的例子,我将在这里贴出来保存所有的读者: 扎克,我遇到了同样的问题。 这是因为你的viewControllerembedded在TabBar控制器或UINavigationController内部,而这些方法的调用发生在那些内部,而不是正常的视图(在iOS6中改变)。 我遇到了这个问题,因为我在一个UINavigationController中embedded了一个viewController,这个viewController在所有的导航到不同视图(注册过程,login等等)的模态视图中。 我简单的修复就是为UINavigationController创build一个包含这两个方法的CATEGORY。 我已经应该说,不pipe怎么说,因为我不想让我的模态视图旋转。 你的修复可能是这个简单的,试试看吧。 希望能帮助到你。 我创build了一个类别并将其命名为autoRotate并select了UINavigationController选项。 下面是M + H文件。 #import "UINavigationController+autoRotate.h" @implementation UINavigationController (autoRotate) -(BOOL)shouldAutorotate { return NO; } – (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } @end …和类别.h: #import <UIKit/UIKit.h> @interface UINavigationController (autoRotate) -(BOOL)shouldAutorotate; – (NSUInteger)supportedInterfaceOrientations; @end 我做了他所说的,并尝试设置类别为我的UITabBarController工作,所有连接到TabBar的类现在只允许orientationPortrait。 但是,如果你看看下面的图片 (从我的项目截图)有一个名为ShowTaskView的StoryBoard中间有一个类。 这个类通过UINavigationController连接到大多数类(它们直接连接到UITabBarController)。 即使我设置UITabBarController只允许肖像也ShowTaskView似乎受该规则的影响,我不能让它旋转。 我的项目中的scheme也可以这样描述: TabBarController —-> UINavigationController ——-> […]

从视图控制器调用poptoviewcontroller函数

让我解释清楚。 我在viewcontroller中有一个tabbarcontoller,它是单视图应用程序项目的主视图控制器。 我添加了一个tabbarcontroller作为子视图的viewcontroller。 在tabbarcontroller中,我添加了两个导航控制器,如下图, 我已经添加了三个(名为第一,第二,第三)更多的视图控制器作为新的文件。 如果我使用下面的方式从一个视图控制器导航到其他视图控制器, third = [[Third alloc] initWithNibName:@"Third" bundle:[NSBundle mainBundle]]; [self.navigationController pushViewController:third animated:YES]; 如果我切换到下一个选项卡并回到上一个选项卡,它应该popup到以前的视图控制器,如何做到这一点? 我试过了 – (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES]; } 不成功, 我也试过了, [third popto]; 在第三个视图控制器中, -(void)popto { [self.navigationController popViewControllerAnimated:YES]; } 什么都没发生。 现在,我必须再次单击该选项卡poptoviewcontroller到第一个视图控制器。 任何想法将不胜感激。

如何popup包含多个导航控制器的视图层次结构的根视图控制器

我有一个与多个 UINavigationControllers的视图层次结构 现在从一个特定的视图控制器,我想popup到window.rootviewcontroller 我怎样才能做到这一点? 我试过了 [UIApplication sharedApplication] .keyWindow.rootViewController popToRootViewController]; 但它不起作用。 请build议。 请注意我想要去window.rootVC。 这不适合我 [self.navigationController popToRootViewControllerAnimated:YES];

UINavigationController子类 – 自定义Pop

像许多其他人一样,我想在UINavigationController中使用“后退”button时执行一个操作。 我知道一些替代方法,例如添加我自己的button,并尝试欺骗的外观,使用viewWillDisappear和设置标签的所有非回操作,将导致视图消失,等等。 但是我想尝试的是inheritanceUINavigationController并在popViewControllerAnimated中注入一些东西: 但是我无法得到一个简单的testing用例。 这是我试过的… 我创build了一个新的类,CustomNavigationController,从UINavigationControllerinheritance。 在这里,我更新了popViewControllerAnimated: 。H: #import <UIKit/UIKit.h> @interface CustomNavigationController : UINavigationController @end .M: #import "CustomNavigationController.h" @interface CustomNavigationController () @end @implementation CustomNavigationController – (UIViewController *)popViewControllerAnimated:(BOOL)animated{ NSLog(@"pop!"); return [super popViewControllerAnimated:animated]; } @end 在界面生成器中,我更改了导航控制器的类: 我错过了什么? 我期待“popup”被logging,每当我popup此导航控制器中的任何视图。

以编程方式推送UINavigationController。 iOS9

我想以编程方式显示导航控制器。 此代码在iOS 8上运行完美,但在iOS 9上不起作用。 var vc = storyboard?.instantiateViewControllerWithIdentifier("view_controller_id") as! UIViewController; var nc = UINavigationController() nc.setViewControllers([vc], animated: false) navigationController?.pushViewController(nc, animated: true) 之后,我得到这个错误 ***由于未捕获的exception“NSInvalidArgumentException”而终止应用程序,原因:“不支持导航控制器”

UITabBarController + UINavigationController和更多选项卡黑屏问题

我目前正在对我的一个应用程序进行更新,而且遇到了与UITabBarController有关的一个非常奇怪的问题。 在我的故事板中,我有大约8个视图控制器,在我的UITabBarController子类中,我添加了另外4个以编程方式加载的视图控制器。 大多数这些视图需要UINavigationController保持一致性,当一些视图从“更多”选项卡出现在主要栏中旋转时,为了做到这一点,我已经将它们embedded到UINavigationController中。 如果您在纵向中select视图6,并且在视图在标签栏中获取其自己的button时旋转,则UINavigationController将变黑,但是当它返回到“更多”时,视图会返回。 在我的这些调查中,似乎UINavigationController将UIViewController作为它的根视图控制器来丢失。 按预期工作,不会进入“更多”选项卡:imgur.com/gVB8wTF 黑屏如果视图来自“更多”选项卡: http : //imgur.com/WaoNoL1 我做了一个快速的示例项目,有这个问题: https : //github.com/joshluongo/UITabBarController-Issues 有想法该怎么解决这个吗?

防止在uinavigationcontroller安装程序中对popViewControllerAnimated进行错误的访问崩溃

所以,在低内存下,我的根视图被卸载。 这是预期的和占的。 但是,如何处理需要popup的模式/推式视图控制器,因为它们引用了主navigationController? 我有一个自定义完成button在推视图控制器,它调用[self.navigationController popViewControllerAnimated:YES]。 如果根视图已被卸载,则会导致访问错误。 有一个更好的方法吗? 我的设置是AppDelegate有一个NavigationController这个NavigationController有一个视图控制器MainViewController //MainViewController.m – (IBAction)showAnotherController:(id)sender { AnotherViewController * anotherViewController; anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil]; [self.navigationController pushViewController:anotherViewController animated:YES]; [anotherViewController release]; } //…Here I can simulate a memory warning to force unloading of MainViewController's view //in AnotherViewController.m, called from a custom toolbar item – (IBAction)done:(id)sender { [self.navigationController popViewControllerAnimated:YES]; // bad […]

使用ios和storyboard编程UIViewControllers循环

我刚刚开始使用IOS 5和故事板的IOS开发,想知道如何解决以下问题: 我有一个树分层结构,其中产品是树的节点,产品是树叶。 我创build了一个TileViewController视图来显示特定级别的所有节点。 当用户在TileView中select一个节点时,根据其types(叶或非叶),我将新的TileViewController推入应用程序NavigationController,或者显示一个DetailViewController。 我现在做的是以编程方式做所有事情(我的意思是跟踪用户在TileViewController中点击了什么,并决定在NavigationController中下一步要做什么)。 我得到了一个故事板的句柄,并使用下面的代码来创build下一个TileViewController(如果需要的话)。 UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; TileViewController *controller = [storyBoard instantiateViewControllerWithIdentifier:@"TileViewController"]; controller.model = self.model; [self.navigationController pushViewController:controller animated:YES]; 我无法弄清楚的是如何在TileViewController中使用故事板而不是硬编码逻辑。 这是可能吗? 我想过使用一个TileViewController,只是重新加载基于用户select显示的瓷砖,但后来我失去了导航片。 任何想法我怎么能做到这一点? 谢谢。