Tag: uinavigationcontroller

为什么使用UINavigationController时无法强制横向?

我发现很多问题强制UIViewController风景作为默认值: 如何强制UIViewController纵向在iOS 6中试试这个: – (BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } – (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeLeft; } 但是当我在UINavigationController里面使用UIViewController的时候,我不能强迫使用landscape.Please help! *工作不好 – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController:self.viewController]; [navControl setNavigationBarHidden:YES]; self.window.rootViewController = navControl; [self.window makeKeyAndVisible]; […]

如何更改导航栏的后退button的字体?

如何更改我的导航栏的后退button的字体。 后退button是“返回”或从前一个视图控制器的标题。 我认为这viewDidLoad将工作: navigationController?.navigationItem.leftBarButtonItem?.setTitleTextAttributes([NSFontAttributeName: UIFont(name: "FONTNAME", size: 20)!], forState: UIControlState.Normal) 但是leftBarButton? 可选返回nil 。

UINavigationController强制旋转

我的应用程序主要是肖像,但有一个视图需要横向。 我的意见是包含在一个UINavigationController,这(显然)是这个问题的原因。 所有UIViewControllers除了一个有这样的: – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } 需要横向的UIViewController有这样的: – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); } 现在,当用户到达横向UIViewController时会发生什么情况,它是以纵向显示的。 用户可以旋转他们的手机,并根据需要显示在横向(locking到横向)。 用户然后继续前进到一个肖像UIViewController,同样的情况发生:它开始在横向,然后他们旋转他们的手机,并再次成为肖像(locking肖像)。 看起来方向locking是允许的UIViewControllers之间,但自动旋转/编程方式改变方向以某种方式被阻止。 如何强制手机更新到正确的方向? 有一个临时的解决scheme:我可以检测设备的方向,并显示一条消息,要求他们旋转设备,如果不正确,但这不是最佳的。

按下UINavigationController的后退button时执行动作

当按下UINavigationController的后退button时,我需要执行一个操作(清空数组),同时button仍然会导致堆栈中的前一个ViewController出现。 我怎么能用swift来完成这个?

将子视图控制器添加到当前视图控制器

我试图通过使用下一个代码添加一个子视图控制器的代码,从故事板到当前的视图控制器: UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil]; LogInTutorialViewController *lvc = [[LogInTutorialViewController alloc] init]; lvc = (LogInTutorialViewController *)[storyboard instantiateViewControllerWithIdentifier:@"LogInTutorialViewControllerID"]; [self displayContentController:lvc]; – (void) displayContentController: (LogInTutorialViewController*) content; { //add as childViewController [self addChildViewController:content]; [content didMoveToParentViewController:self]; [content.view setFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)]; [self.view addSubview:content.view]; } 视图似乎至less在模拟器上显示,但在控制台我得到很多或错误: <Error>: CGContextSaveGState: invalid context 0x0. This is a serious error. […]

iOS 7 – navigationController设置我的UIScrollView的contentInset和ContentOffset

我有一个UIScrollView(实际上是一个UICollectionView,但可能无所谓)。 当它出现在IOS 7中时,导航控制器将其contentInset和contentOffset设置为我不想要的值。 它似乎在尝试调整状态栏和导航栏。 我非常喜欢这让他们孤单。 我已经通过覆盖contentInset和contentOffset的getter和setter方法解决了这个问题,用一个标志来告诉对象是否应该接受一个set。 但有没有更好的办法?

如何正确使用导航控制器来实现标签栏控制器

我正在使用Storyboard和Xcode 6.我的Storyboard中有下一个控制器和场景: 具有HomeViewController作为根的UINavigationController 。 HomeViewController有一个button, Show (eg Push) UITabBarController 。 UITabBarController有4个UIViewControllers 。 但是我的问题是,在显示UITabBarController后,在4个UIViewControllers中没有导航栏。 但我认为,如果我Show (eg Push) UITabBarController那么它应该embedded导航控制器,在故事板中的初始控制器。 我对吗? 如果是这样,我怎么能安装导航栏在故事板,因为现在有默认的酒吧事件在推介标签栏,我在故事板上看到。 我已经select了UIViewController,并在身份检查器中设置模拟度量为Top属性的半透明导航栏,但我认为它应该自动添加到此控制器和标签栏,而无需额外的步骤。 或者我应该添加新的导航控制器的每个标签栏项目将有他们的根视图控制器? 主要问题,为什么我看不到导航栏使用显示(例如推)故事板。 例如,如果我添加导航控制器,然后设置为根标签栏控制器,然后Xcode自动添加顶部导航栏,但如果队列有一个额外的步骤像在我的情况HomeViewController顶部导航栏永远不会自动出现。

尝试在iOS中处理“返回”导航button操作

我需要检测用户点击导航栏上的“后退”button,以便在发生这种情况时执行某些操作。 我试图手动设置这样的button,这样的行动: [self.navigationItem.backBarButtonItem setAction:@selector(performBackNavigation:)]; – (void)performBackNavigation:(id)sender { // Do operations [self.navigationController popViewControllerAnimated:NO]; } 我首先将代码放在视图控制器本身,但是我发现self.navigationItem.backBarButtonItem似乎是nil ,所以我将相同的代码移动到父视图控制器,它将前者推到导航堆栈。 但我无法做到这一点。 我已经阅读了关于这个问题的一些post,其中一些人说,select器需要设置在父视图控制器,但对我来说它不工作呢…我做错了什么? 谢谢