Tag: uiviewcontroller

我如何从导航控制器中删除一个视图

我想调用一个新的视图控制器,并从导航控制器堆栈中删除当前的视图控制器。 例如。 我在视图控制器A和我打电话B. 现在我已经在堆栈A,B了。现在我想打电话给C(从B)。 我想堆栈是A,C 谢谢。

推视图控制器,黑屏

我正在推动一个新的视图控制器,并将一些数据传递给它。 当我运行应用程序,我可以按下button,并推到新的视图,但屏幕是完全黑色的。 任何帮助表示赞赏。 – (IBAction)button:(id)sender { NSString *firstField = self.field.text; NSString *secondField = self.field2.text; self.resultsArray = [[NSArray alloc] initWithObjects:firstField, secondField, nil]; NSUInteger randomResult = arc4random_uniform(self.resultsArray.count); self.label.text = [self.resultsArray objectAtIndex:randomResult]; ImagesViewController *ivc = [[ImagesViewController alloc] init]; ivc.label = self.label.text; [self.navigationController pushViewController:ivc animated:YES]; }

如何设置子视图控制器的topLayoutGuide位置

我正在实现一个自定义的容器,它非常类似于UINavigationController,除了它不包含整个控制器堆栈。 它有一个UINavigationBar,它被限制在容器控制器的topLayoutGuide中,它恰好是顶部20px,这是OK的。 当我添加一个子视图控制器并将其视图放入层次结构中时,我希望在IB中看到它的topLayoutGuide,并用于布置子视图控制器的视图的子视图,使其出现在导航栏的底部。 在相关的文件中有一个要做的事情: 此属性的值特别是查询此属性时返回的对象的length属性的值。 该值受到视图控制器或其封闭容器视图控制器(如导航或选项卡栏控制器)的约束,如下所示: 不在容器视图控制器中的视图控制器约束此属性以指示状态栏的底部(如果可见) 否则指示视图控制器视图的上边缘。 容器视图控制器中的视图控制器不会设置此属性的值。 相反,容器视图控制器限制值以指示: 导航栏的底部,如果导航栏是可见的 状态栏的底部,如果只有一个状态栏是可见的 视图控制器视图的顶部边缘,如果状态栏和导航栏都不可见的话 但是我不太了解如何“限制它的价值”,因为topLayoutGuide和它的长度属性都是只读的。 我已经试过这个代码来添加一个子视图控制器: [self addChildViewController:gamePhaseController]; UIView *gamePhaseControllerView = gamePhaseController.view; gamePhaseControllerView.translatesAutoresizingMaskIntoConstraints = NO; [self.contentContainer addSubview:gamePhaseControllerView]; NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-0-[gamePhaseControllerView]-0-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(gamePhaseControllerView)]; NSLayoutConstraint *topLayoutGuideConstraint = [NSLayoutConstraint constraintWithItem:gamePhaseController.topLayoutGuide attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.navigationBar attribute:NSLayoutAttributeBottom multiplier:1 constant:0]; NSLayoutConstraint *bottomLayoutGuideConstraint = [NSLayoutConstraint constraintWithItem:gamePhaseController.bottomLayoutGuide attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.bottomLayoutGuide attribute:NSLayoutAttributeTop multiplier:1 […]

从内存中分段并清除历史ViewController

我有一个iPad应用程序,它有很多的屏幕和很多segue选项。 目前,我只是使用performSegueWithIdentifier来启动这些赛段,我担心的是当用户执行越来越多的赛段时,我正在占用大量的内存。 我已经看到,人们build议使用函数popToRootViewControllerAnimated:如果使用UINavigationController,但问题是我没有使用一个。 我怎样才能阻止VC的数量激增? 应用程序的工作方式,用户不断回到根VC – 有效的search屏幕。 所以,如果我能够在需要这样一个轮stream的时候清理VC的堆栈,那么我就可以解决我的问题,但我不知道如何去解决这个问题。 感谢您的任何build议。

链接一个新的视图控制器到故事板?

可能有一个简单的解决scheme,但我无法弄清楚。 我正在使用界面的故事板。 我从一个标签栏控制器开始,但在用户被允许使用该应用程序之前,用户必须通过在开始时模式推送的loginview来validation自己。 我想要在同一个故事板上configurationloginview,但是我不能缝合来弄清楚如何链接故事板上的视图控制器和我的代码。 我做了什么: 创build一个新的UIViewController子类通过文件>新build>新文件。 在故事板中拖放一个新的UIViewController 在自定义类选项卡中设置类 拖动一个UILabel用于testing目的。 跑 无标签…

dismissViewControllerAnimated VS popViewControllerAnimated

我想知道他们有什么不同。 当我可以打电话 [self dismissViewControllerAnimated:YES completion:nil]; 什么时候该打电话 [self.navigationController popViewControllerAnimated:YES]; 根据苹果的文档:dismissViewControllerAnimated的意思是“解除接收器呈现的视图控制器”。 但是我总是不能通过这种方法解雇视图控制器。

Xcode 6 GM iPhone 6模拟器 – 故事板大小不正确,放大显示

我正在使用新的Xcode 6 GM Seed并在iPhone 6和iPhone 6 Plus模拟器上testing我的应用程序。 我在之前的一些项目上得到了一个奇怪的效果,也就是说,这些视图似乎正在获得“放大”的效果。 这是一个例子。 这两个视图控制器是完全相同的(减去不同的导航项目文本),直到标签文本大小。 但是,您可以看到视图显示不同。 放大 正常 请注意,具有怪异缩放效果的项目具有8.0的部署目标。 注意:通过在新的Xcode 6 GM种子中制作项目(不工作的项目是在旧版本的Xcode上制作的),我得到了正常的工作。

viewWillAppear,viewDidAppear,viewWillDisappear,viewDidDisappear指南

是否有正确使用这些方法的指导原则? 特别是,我想知道我可以在里面使用什么types的代码。 例如,如果我必须调用一个从WS中检索数据的方法,那么我应该在哪里调用它? 我可以在哪里注册/取消注册NSNotification? 等等

视图控制器正在发送一条消息,即使它已被释放

我不确定在iPhone SDK 3.0中有什么改变,但我得到最奇怪的错误。 我有一个视图控制器层次结构,我根据界面方向在视图控制器之间切换。 从我可以告诉,错误是造成每当我旋转接口已被释放视图控制器正在发送一个shouldAutorotateToInterfaceOrientation消息。 这是错误的回溯: #0 0x01dc43a7 in ___forwarding___ #1 0x01da06c2 in __forwarding_prep_0___ #2 0x002e6733 in -[UIWindow _shouldAutorotateToInterfaceOrientation:] #3 0x002e6562 in -[UIWindow _updateToInterfaceOrientation:duration:force:] #4 0x002e6515 in -[UIWindow _updateInterfaceOrientationFromDeviceOrientation] #5 0x0004d63a in _nsnote_callback #6 0x01d8f005 in _CFXNotificationPostNotification #7 0x0004aef0 in -[NSNotificationCenter postNotificationName:object:userInfo:] #8 0x0045b454 in -[UIDevice setOrientation:] #9 0x002d6890 in -[UIApplication handleEvent:withNewEvent:] #10 0x002d16d3 in […]

UIViewController旋转方法

什么对象负责对UIViewController旋转方法的调用,即: shouldAutorotateToInterfaceOrientation: willRotateToInterfaceOrientation:duration: willAnimateFirstHalfOfRotationToInterfaceOrientation:duration: willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration: didRotateFromInterfaceOrientation: 我想这是UIApplication (但也许是AppDelegate或UIWindow)。 接下来的问题是,对象如何知道要与哪个UIViewController交谈? 它如何知道哪个UIViewController的视图作为窗口的子视图? 有没有一个消息,你可以发送或一个属性,你可以设置(的一些对象),为应用程序设置“活动” UIViewController ?