I can't change initial Xcode storyboard view - xcode4

I'm trying to change my initial view in my storyboard, but, when I change it I get this strange view:
Anyone can tell me why?
Ps: In my project I don't have any tab controllers, so I don't know why there is a tab over there...

Is it possible you are doing a universal app and are looking at the wrong View?
What you have there is a navigation bar in a blank view and probably a message in your messages telling you that you have not got a root view controller.
In the past I have solved this by
a) Restarting XCode.
b) Making a new view, copying and pasting the essential View Controller from my old View and deleting the old View.
c) Checking in my summary that the view I think is being talked to actually is the one specified.
d) Looking at my storyboard and checking that the viewcontroller is specified in the object inspector as "Is initial View Controller" by checking the box.

Related

NavigationController and View Hierarchy issue

I have 1 (rootViewController) view controller which is embedded in navigation controller. Then i pushed another view controller (secondViewController), which has search controller in title view. When i am trying search become first responder (Active) i got this in terminal:
Warning: Attempt to present
"AppName.CustomSearchViewController: 0x7face0c20eb0> on
whose view is
not in the window hierarchy!
This happens only in iOS lower than 11. When i embed this second view controller in navigation controller and present it modally all works good, but i need exactly pushing. How can i solve this?
I solved it! I need to make definesPresentationContext false in rootViewController to make it work on another one!

Xamarin.Mac -- AppDelegate DidFinishLaunching -- Is the "Main Interface" specified in Info.plist already supposed to be loaded?

I have an existing .xib that needs to be displayed as the main page in a Xamarin.Mac application. If I set the "Main Interface" as this existing .xib, it does display but it's not done by the time my DidFinishLaunching override gets called. This is where I expect to do some initialization, but the outlets I specified are all null.
I am new to Xamarin and I'm trying to figure out if I need to override a different call that lets me know that the main page is done loading or if the issue lies elsewhere.
I did see that an NSWindowController has a WindowDidLoad override, but if I set the Main Interface in the info.plist, how does it know what the ViewController is for that view so that my override WindowDidLoad gets called?
I'm thinking I probably need to create the main window manually in DidFinishLaunching, but I can't find any documentation on how to create the main window through an .xib. There is documentation on how to get a storyboard from a nib, but I am not seeing anything on loading a .xib. If someone can find a good reference on how the main window gets initialize (with all the plumbing included) in a Xamarin.Mac application, that may be enough.
Thank you in advance for your time.
The chain of events is roughly:
Main invokes NSApplication.Main
Reads Info.plist to determine what xib/storyboard to load.
Storyboard is loaded and inflated. The view controller has a custom class that points to "ViewController"
Your ViewController is spun up, and WindowDidLoad get called.
DidFinishLaunching is not exactly what you are looking for.
May I suggest take a look at the documentation in question to get a better understand of the full process:
https://developer.xamarin.com/guides/mac/getting_started/hello,_mac/#Anatomy_of_a_Xamarin.Mac_Application

How to Uninstall a UIView programmatically

In Interface builder the power of size classes lets you install constraints or uninstall them. In code you can do something similar by toggling the active property.
Interface Builder also lets you install or uninstall views. However, I would like to be able to do this programatically. UIView doesn't appear to have an active property. Is there any way I can uninstall a view programmatically? I'm looking for something where I can simply toggle a boolean property and the view and its constraints go into a dormant state and the view is no longer visible ands its constraints are no longer constraining until it is toggled to be non-dormant and then the view and the constraints work again.
Is this possible? Any workarounds?
A view's hidden property does not equate to the view being installed or not. From the Apple documentation on Installing and Uninstalling Views for a Size Class:
A runtime object for an uninstalled view is still created. However,
the view and any related constraints are not added to the view
hierarchy and the view has a superview property of nil. This is
different from being hidden. A hidden view is in the view hierarchy
along as are any related constraints.
So it sounds like the equivalent in code is something like:
// "Uninstall" the view from the superview
[self.myView removeFromSuperView];
// And add it back in
[self.view addSubview:self.myView]
You'd still have the view in memory, though not hidden. However you go about this I'm guessing your activating and deactivating constraints as this view comes and goes (unless the view itself is overlaying other things on the screen and not requiring a rearrangement of objects).

Combining a navigationcontroller and a root view controller with pages

I have a problem that has been solved on iOS6, but still appears if I use the iOS 5.1 simulator.
I have a default page based application. I added a "Main menu" view controller, that has three buttons that activate the root view controller containing the pages via a push segue, all defined in the storyboard.
I then added a navigation controller and made it the initial view controller.
If I pas the menu via a button and flip a few pages I can click the back button and it goes back to the menu. Good.
But I don't want the nav bar, so I hide it, and on the root view controller that contains the page view controllers I add a button which performs this action:
[self.navigationController popToRootViewControllerAnimated:YES];
This button works perfect on iOS6, I can flip a few pages, press the button and I'm back in the menu.
With the iOS 5.1 simulator however (and on my 5.1 iPad), a page flip occurs! It's a page filp until I'm on the last page and then I go back to the menu.
I searched for over two hours now but could not find a solution, I hope someone can help me with this?
Note: setting animated to NO does not solve the problem.
I did find the answer to my question, this is my first iOS project which explains why I did not find it any sooner myself.
In the default page based application there are two lines in the viewDidLoad method:
// Add the page view controller's gesture recognizers to the book view controller's view so that the gestures are started more easily
self.view.gestureRecognizers = self.pageViewController.gestureRecognizers;
First, it's not really adding but assigning that happens here, second, when I put the second line in comment, everything works as expected.
So I'm glad it solves my problem, however it raises some questions:
The gestures are started as easy as they were, so why was this line needed in the first place, what does it supposedly fix?
Why does it work in iOS6? It should have had the same problem, no?
Is it correct that it is an assignment and not an addition?
Any answers to these three are still appreciated.
Alex

Autorotate with a UINavigationController

I am a little unclear on how to rotate views that are sitting on a UINavigationController.
I have overridden the UINavigationController object with one of my own that overrides:
(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { return YES; }
I have one view on the stack on the controller and that view is loaded from a xib with two views in it. I want to switch from portrait to landscape. Normally I would handle this by changing the view from within the nib files of the view itself. Do I have to implement the rotational code within the Navigation Controller or just within my view code?
(void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
That willAnimate code is what I'm used to using in the view itself, but I'm still not seeing the view being changed, and I'm thinking it may be that I need to access the view in the NavigationController and change that, or even override the same method in the Navigation Controller and do my view switching there.
Any suggestions? I've never actually done this before and just found out the TabViewControllers and NavigationControllers are both portrait mode only by default.
Turns out it wasn't possible to change the view because I was trying to changes the RootView on the Navigation Controller. I got around this by placing my own pseudo root view controller that never gets seen in the root spot on the Navigation stack. I overrode a few of the navigation controls to account for this so the functionality would continue the same and I'd be able to change my desired perceived root view as I needed to.
A start in the right direction can be found in this link:
http://starterstep.wordpress.com/2009/03/05/changing-a-uinavigationcontroller’s-root-view-controller/

Resources