uiviewcontroller

Assign a value to a controller property in Swift

二次信任 提交于 2019-12-23 14:24:52
问题 I am trying to pass an int variable between views in Swift but I'm not sure how to access the other View controller's property. In Objective C I would do something like this UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; AnsViewController *ansViewController = [storyBoard instantiateViewControllerWithIdentifier:@"ansView"]; ansViewController.num = theNum; [self presentViewController:ansViewController animated:YES completion:nil]; And in the other

iOS Segue - When are the viewControllers Instantiated

青春壹個敷衍的年華 提交于 2019-12-23 13:08:59
问题 I have a simple storyboard with a Main View Controller and two Detail view Controllers as shown in the diagram. Question #1 - Where is the code that SequeA will present DetailA located Question #2 - In my code for the AppDelegate I need to create an array of all the ViewControllers that are in the App - How can I get that array? - It is in the story board but how do I programmatically access it. I can get the MainViewController by doing the following - myViewControllerMain =

Create an array of objects that implements a specific protocol

天大地大妈咪最大 提交于 2019-12-23 12:58:31
问题 TL;DR I'm looking for an array type ( var array = [TheTypeImLookingFor]() ) like 'all objects that subclasses UIViewController and implements the protocol MyProtocol . Explanation I'm building a kind of wizard view with a container view and embedded child views (controller). No problem, this will work as long, as I have only one base type of child view controllers. Due to the content of screens, I have now a bunch of view controllers of type MyTableViewController which is a subclass of

How to dismiss a stack of modal view controllers with animation without flashing on screen any of the presented VCs between the top and bottom?

梦想与她 提交于 2019-12-23 11:39:12
问题 UPDATED: Fixed via "screenshot" method outline below. This works but is there a more elegant way? How would I go about dismissing a stack of modal view controllers with animation without flashing on screen any of the presented VCs between the top and bottom? Trying to do this with animation isn't working. See code below and inline comments describing my issue. You can copy/paste this code into a new project in Xcode to see for yourself if you'd like! // // ViewController.m // MultipleModals /

Why does using setViewControllers remove everything from the UINavigationController's nav bar?

◇◆丶佛笑我妖孽 提交于 2019-12-23 10:44:34
问题 Here's the issue. I use the following code in a UINavigationController to swap the rootViewController . I need to be able to swap the rootViewController between a number of different screens and allow the user to drill down from each screen (which is obviously why I need the Nav Controller): SomeViewController *tmp = [[SomeViewController alloc] initWithNibName:@"SomeViewController" bundle:nil]; NSArray * viewControllers = [self viewControllers]; NSArray * newViewControllers = [NSArray

Why does using setViewControllers remove everything from the UINavigationController's nav bar?

我的梦境 提交于 2019-12-23 10:44:15
问题 Here's the issue. I use the following code in a UINavigationController to swap the rootViewController . I need to be able to swap the rootViewController between a number of different screens and allow the user to drill down from each screen (which is obviously why I need the Nav Controller): SomeViewController *tmp = [[SomeViewController alloc] initWithNibName:@"SomeViewController" bundle:nil]; NSArray * viewControllers = [self viewControllers]; NSArray * newViewControllers = [NSArray

Auto layout of a Child Container that embeds a UIViewController

£可爱£侵袭症+ 提交于 2019-12-23 10:17:50
问题 My main scene shows a child UIViewController , by putting a Child Container in its View, and embedding a child UIViewController in that Child Container. I do that by ctrl-dragging from the Child Container to the child UIViewController in the storyboard , and choosing the "embed" segue. That lets me encapsulate and reuse the child UIViewController elsewhere. I think that is fairly standard. But I can't get it to auto layout properly. I've made a simple test case to demonstrate this: https:/

Push segue in iOS 5 not working

烂漫一生 提交于 2019-12-23 09:39:08
问题 I am very much new to IOS. I am using the storyboard feature to create a app Here is what I want. I have two view Controllers, say oneViewController and twoViewController I have a button on oneViewController. I ctrl+dragged the button from oneViewController to twoViewController and selected push from Segue. I compiled the app on iOS 5.0 and run it, and it's not working. I changed push to model and it worked. Am I missing anything? I am using the a part of this link and this link as a guidance

UIViewControllerAnimatedTransitioning with Safe Area Insets on iPhone X

前提是你 提交于 2019-12-23 09:11:17
问题 When animateTransition is called on the transitioning delegate the Safe Area Insets have yet to be set on the 'to view controller'. I've tried forcing a layout by calling: toViewController.view.setNeedsLayout() and toViewController.view.layoutIfNeeded() without success. Can anyone suggest a means of either forcing the Safe Area Insets to be set early or determining how I should know the insets in time for the transition to work as it ought. The effect is that I have a UICollectionViewCell

How to load a XIB with a top-level ViewController?

拈花ヽ惹草 提交于 2019-12-23 08:47:34
问题 I've got a nib with a view controller root element like this: so I can position elements relative to the top and bottom layout guides using auto-layout. When I first tried to load this nib using SearchViewControllerPro* searchViewController = [[SearchViewControllerPro alloc]initWithNibName:@"SearchViewControllerPro" bundle:[NSBundle mainBundle]]; I got the following run-time exception: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController